[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) <jpp@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2020-10-23 09:09:21 +00:00
parent 588086235e
commit 7b06e6c8b6
@@ -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: