diff --git a/addons/account_edi/models/account_move.py b/addons/account_edi/models/account_move.py index fc1bdf414db..69cafa7565e 100644 --- a/addons/account_edi/models/account_move.py +++ b/addons/account_edi/models/account_move.py @@ -402,6 +402,12 @@ class AccountMove(models.Model): def _get_edi_attachment(self, edi_format): return self._get_edi_document(edi_format).sudo().attachment_id + # this override is to make sure that the main attachment is not the edi xml otherwise the attachment viewer will not work correctly + def _message_set_main_attachment_id(self, attachment_ids): + if self.message_main_attachment_id and len(attachment_ids) > 1 and self.message_main_attachment_id in self.edi_document_ids.attachment_id: + self.message_main_attachment_id = self.env['ir.attachment'] + super()._message_set_main_attachment_id(attachment_ids) + #################################################### # Business operations ####################################################