From a64476635e14fd557f33b43722ddc19a6458a562 Mon Sep 17 00:00:00 2001 From: Louis Baudoux Date: Wed, 28 Aug 2019 13:56:42 +0000 Subject: [PATCH] [FIX] account: fix main_attachment_id not set on attachment upload When creating invoices via the 'Upload' button, the 'message_main_attachment_id' field wasn't set on the record. This happened because the message posted in the chatter was linked to the wrong 'res_model' which prevented it from being selected as the main attachment. This was causing a bug in the OCR module ('account.invoice.extract') where we use this field to determine which attachment must be sent to the OCR server. closes odoo/odoo#36309 Signed-off-by: Florian Daloze (fda) --- addons/account/models/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index f833430b4af..0f532a2afdc 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -1044,7 +1044,7 @@ class AccountJournal(models.Model): invoices = self.env['account.move'] for attachment in attachments: invoice = self.env['account.move'].create({}) - attachment.write({'res_model': 'account.move', 'res_id': invoice.id}) + attachment.write({'res_model': 'mail.compose.message'}) invoice.message_post(attachment_ids=[attachment.id]) invoices += invoice