[FIX] account_facturx: retrieve attachments in the right way to create an invoice

Before that, we relied on the fact the call to super() assigned the attachment_ids field, which was wrong outside mail.compose.message. Hence, we fix that by directly browsing the attachment.

closes odoo/odoo#36552

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
oco-odoo
2019-09-09 10:54:11 +00:00
parent 55e1b44492
commit 5cf9d55bbc
@@ -222,7 +222,7 @@ class AccountMove(models.Model):
res = super(AccountMove, self).message_post(**kwargs)
if 'no_new_invoice' not in self.env.context and len(self) == 1 and self.state == 'draft':
for attachment in res.attachment_ids:
for attachment in self.env['ir.attachment'].browse(kwargs.get('attachment_ids', [])):
self._create_invoice_from_attachment(attachment)
return res