[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:
@@ -222,7 +222,7 @@ class AccountMove(models.Model):
|
|||||||
res = super(AccountMove, self).message_post(**kwargs)
|
res = super(AccountMove, self).message_post(**kwargs)
|
||||||
|
|
||||||
if 'no_new_invoice' not in self.env.context and len(self) == 1 and self.state == 'draft':
|
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)
|
self._create_invoice_from_attachment(attachment)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user