diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index db0837ebdc9..fd07c82bb42 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2892,17 +2892,15 @@ class AccountMove(models.Model): return rslt - @api.returns('mail.message', lambda value: value.id) - def message_post(self, **kwargs): + def _message_post_after_hook(self, new_message, message_values): # OVERRIDE # When posting a message, check the attachment to see if it's an invoice and update with the imported data. - res = super().message_post(**kwargs) + res = super()._message_post_after_hook(new_message, message_values) - attachment_ids = kwargs.get('attachment_ids', []) - if len(self) != 1 or not attachment_ids or self.env.context.get('no_new_invoice') or not self.is_invoice(include_receipts=True): + attachments = new_message.attachment_ids + if len(self) != 1 or not attachments or self.env.context.get('no_new_invoice') or not self.is_invoice(include_receipts=True): return res - attachments = self.env['ir.attachment'].browse(attachment_ids) odoobot = self.env.ref('base.partner_root') if attachments and self.state != 'draft': self.message_post(body=_('The invoice is not a draft, it was not updated from the attachment.'),