[IMP] account: mark invoice as sent once pdf generated
Before this commit, the invoices were marked as sent only when sending them via email or post. After, it is mark as sent once the PDF is being generated via the send&print wizard, as it becomes computed based on the presence of the PDF. Rational, we want to consider a generated invoice via the send&print wizard as being sent as it can be printed/downloaded. This also makes the invoice available in the portal. closes odoo/odoo#117085 X-original-commit: 9e656aabe4f6840ee5c200a21832dad958ea6892 Signed-off-by: Laurent Smet <las@odoo.com> Signed-off-by: Detry Thomas (det) <det@odoo.com>
This commit is contained in:
@@ -502,8 +502,11 @@ class AccountMove(models.Model):
|
||||
default=False,
|
||||
copy=False,
|
||||
tracking=True,
|
||||
help="It indicates that the invoice/payment has been sent.",
|
||||
store=True,
|
||||
compute="_compute_is_move_sent",
|
||||
help="It indicates that the invoice/payment has been sent or the PDF has been generated.",
|
||||
)
|
||||
|
||||
invoice_user_id = fields.Many2one(
|
||||
string='Salesperson',
|
||||
comodel_name='res.users',
|
||||
@@ -610,6 +613,11 @@ class AccountMove(models.Model):
|
||||
# COMPUTE METHODS
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@api.depends('invoice_pdf_report_id')
|
||||
def _compute_is_move_sent(self):
|
||||
for move in self:
|
||||
move.is_move_sent = bool(move.invoice_pdf_report_id)
|
||||
|
||||
def _compute_payment_reference(self):
|
||||
for move in self.filtered(lambda m: (
|
||||
m.state == 'posted'
|
||||
|
||||
@@ -343,7 +343,6 @@ class AccountMoveSend(models.Model):
|
||||
'reply_to_force_new': False,
|
||||
},
|
||||
)
|
||||
move.is_move_sent = True
|
||||
|
||||
def _send_mails(self, moves):
|
||||
subtype = self.env.ref('mail.mt_comment')
|
||||
@@ -393,6 +392,7 @@ class AccountMoveSend(models.Model):
|
||||
# note: Binary is used for security reason
|
||||
self.env['ir.attachment'].create(prepared_data['pdf_attachment_values'])
|
||||
invoice.invalidate_model(fnames=['invoice_pdf_report_id', 'invoice_pdf_report_file'])
|
||||
self.env.add_to_compute(invoice._fields['is_move_sent'], invoice)
|
||||
|
||||
def _postprocess_document(self, invoice, prepared_data):
|
||||
""" Postprocess prepared_data before it gets linked to the record
|
||||
|
||||
@@ -68,6 +68,4 @@ class AccountMoveSend(models.Model):
|
||||
])\
|
||||
._snailmail_print(immediate=False)
|
||||
|
||||
moves.is_move_sent = True
|
||||
|
||||
return moves
|
||||
|
||||
Reference in New Issue
Block a user