[FIX] account_facturx: fixed traceback

issue: a traceback is faced when configured a journal alias to create
invoice/bill when fetching emails with a pdf file from that alias.

closes odoo/odoo#34740

Task: 34740
Closes: #34740
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
Hetashree Chauhan
2019-09-06 07:12:06 +00:00
committed by Ravi Gohil
parent 4a1bbbff75
commit bccc78a7f4
@@ -222,15 +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':
# Get attachments.
# - 'attachments' is a namedtuple defined in mail.thread looking like:
# _Attachment = namedtuple('Attachment', ('fname', 'content', 'info'))
# - 'attachment_ids' is a list of ir.attachment records ids.
attachments = kwargs.get('attachments', [])
if kwargs.get('attachment_ids'):
attachments += self.env['ir.attachment'].browse(kwargs['attachment_ids'])
for attachment in attachments:
for attachment in res.attachment_ids:
self._create_invoice_from_attachment(attachment)
return res