diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index b344731561f..86081a1b3a4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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' diff --git a/addons/account/wizard/account_move_send.py b/addons/account/wizard/account_move_send.py index 9062510d248..dbd47aaef6a 100644 --- a/addons/account/wizard/account_move_send.py +++ b/addons/account/wizard/account_move_send.py @@ -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 diff --git a/addons/snailmail_account/wizard/account_move_send.py b/addons/snailmail_account/wizard/account_move_send.py index 5e166f92102..0b78ff7afb6 100644 --- a/addons/snailmail_account/wizard/account_move_send.py +++ b/addons/snailmail_account/wizard/account_move_send.py @@ -68,6 +68,4 @@ class AccountMoveSend(models.Model): ])\ ._snailmail_print(immediate=False) - moves.is_move_sent = True - return moves