summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Pinna Puissant <jpp@odoo.com>2020-10-16 11:13:37 +0000
committerJorge Pinna Puissant <jpp@odoo.com>2020-10-16 11:13:37 +0000
commit7313e9823fffcac747af633b9b1694aa661dfa1f (patch)
tree3f6863d2acce9ccaebea4a2a7c008443b26eec73
parent232a3c4c65dd60215a5def010da8559a9ffb2378 (diff)
[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#60163 Related: odoo/enterprise#14167 Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
-rw-r--r--addons/account_edi/models/account_edi_document.py10
1 files 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: