From 7b06e6c8b6599d958c2270fde4fbcb3688bed876 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Fri, 16 Oct 2020 11:13:37 +0000 Subject: [PATCH] [FIX] account_edi: allow attachment and error in same document Allow having in an attachment as well as an error in the same document. This will allow to see the document that generates the error, and easy the process of debugging. closes odoo/odoo#60599 X-original-commit: 7313e9823fffcac747af633b9b1694aa661dfa1f Related: odoo/enterprise#14357 Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/account_edi/models/account_edi_document.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/account_edi/models/account_edi_document.py b/addons/account_edi/models/account_edi_document.py index af128e474f8..b1bd59193cd 100644 --- a/addons/account_edi/models/account_edi_document.py +++ b/addons/account_edi/models/account_edi_document.py @@ -80,11 +80,13 @@ class AccountEdiDocument(models.Model): move_result = edi_result.get(move, {}) if move_result.get('attachment'): old_attachment = document.attachment_id - document.write({ + values = { 'attachment_id': move_result['attachment'].id, - 'state': 'sent', - 'error': False, - }) + 'error': move_result.get('error', False), + } + if not values.get('error'): + values.update({'state': 'sent'}) + document.write(values) if not old_attachment.res_model or not old_attachment.res_id: attachments_to_unlink |= old_attachment else: