summaryrefslogtreecommitdiff
path: root/addons/account_edi
diff options
context:
space:
mode:
authorBenjamin Frantzen (bfr) <bfr@odoo.com>2021-02-08 08:11:13 +0000
committerBenjamin Frantzen (bfr) <bfr@odoo.com>2021-02-08 08:49:37 +0000
commit385fa29322f6dffc7d7d0de96a1cfbddb0cab7f0 (patch)
treeb06c2ca61074866c12fbf88b4536a53395b12861 /addons/account_edi
parenta7c4533a9bca17dce436a1f4a495df513fe3ccf1 (diff)
[FIX] account_edi: edi.document are re-send if they are in error
Before the introduction of account_edi_extended and blocking_level, if an edi.document was in error, it was retried each the time the edi.documents were processed. With account_edi_extended a bug was introduced and only the document not in error were processed. This commit aims to restore the previous behavior. Also fixes tests of account_edi. See https://github.com/odoo/odoo/commit/a9a46cf09b0c841c7fda95b5ed03033fc6936ca2
Diffstat (limited to 'addons/account_edi')
-rw-r--r--addons/account_edi/models/account_move.py2
-rw-r--r--addons/account_edi/tests/common.py2
-rw-r--r--addons/account_edi/tests/test_edi.py12
3 files changed, 12 insertions, 4 deletions
diff --git a/addons/account_edi/models/account_move.py b/addons/account_edi/models/account_move.py
index a8cbe445e53..b69cf611e5b 100644
--- a/addons/account_edi/models/account_move.py
+++ b/addons/account_edi/models/account_move.py
@@ -236,8 +236,6 @@ class AccountMove(models.Model):
docs = self.edi_document_ids.filtered(lambda d: d.state in ('to_send', 'to_cancel'))
if 'blocking_level' in self.env['account.edi.document']._fields:
docs = docs.filtered(lambda d: d.blocking_level != 'error')
- else:
- docs = docs.filtered(lambda d: not d.error)
docs._process_documents_web_services(with_commit=False)
class AccountMoveLine(models.Model):
diff --git a/addons/account_edi/tests/common.py b/addons/account_edi/tests/common.py
index b3151b95570..28eb26d3def 100644
--- a/addons/account_edi/tests/common.py
+++ b/addons/account_edi/tests/common.py
@@ -90,7 +90,7 @@ class AccountEdiTestCommon(AccountTestInvoicingCommon):
:param move: The move of the document or None to create a new one.
:param move_type: If move is None, the type of the invoice to create, defaults to 'out_invoice'.
"""
- move = move or self.init_invoice(move_type or 'out_invoice')
+ move = move or self.init_invoice(move_type or 'out_invoice', products=self.product_a)
return self.env['account.edi.document'].create({
'edi_format_id': edi_format.id,
'move_id': move.id,
diff --git a/addons/account_edi/tests/test_edi.py b/addons/account_edi/tests/test_edi.py
index 02bde5f8d12..85baee809b4 100644
--- a/addons/account_edi/tests/test_edi.py
+++ b/addons/account_edi/tests/test_edi.py
@@ -8,7 +8,7 @@ from unittest.mock import patch
class TestAccountEdi(AccountEdiTestCommon):
def test_export_edi(self):
- invoice = self.init_invoice('out_invoice')
+ invoice = self.init_invoice('out_invoice', products=self.product_a)
self.assertEqual(len(invoice.edi_document_ids), 0)
invoice.action_post()
self.assertEqual(len(invoice.edi_document_ids), 1)
@@ -37,3 +37,13 @@ class TestAccountEdi(AccountEdiTestCommon):
with patch('odoo.addons.account_edi.models.account_edi_format.AccountEdiFormat._support_batching', return_value=True):
to_process = edi_docs._prepare_jobs()
self.assertEqual(len(to_process), 2)
+
+ @patch('odoo.addons.account_edi.models.account_edi_format.AccountEdiFormat._post_invoice_edi')
+ def test_error(self, patched):
+ with patch('odoo.addons.account_edi.models.account_edi_format.AccountEdiFormat._needs_web_services',
+ new=lambda edi_format: True):
+ edi_docs = self.create_edi_document(self.edi_format, 'to_send')
+ edi_docs.error = 'Test Error'
+
+ edi_docs.move_id.action_process_edi_web_services()
+ patched.assert_called_once()