From 5d323574ec7b3465bfae43ab04f5fb4a983732bd Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Wed, 27 Apr 2022 10:15:29 +0000 Subject: [PATCH] [FIX] l10n_es_edi: no commits in tests When processing web services for test purposes, use with_commit=False Avoids multiple potential psycopg2 errors closes odoo/odoo#90546 X-original-commit: a08d09e0e12d026b27a7a8434edcac0aa6b3c501 Signed-off-by: Laurent Smet Signed-off-by: Stanislas Gueniffey (stgu) --- addons/account_edi/models/account_move.py | 4 ++-- addons/l10n_es_edi_sii/tests/test_edi_web_services.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account_edi/models/account_move.py b/addons/account_edi/models/account_move.py index 3799faa645c..181ed78e059 100644 --- a/addons/account_edi/models/account_move.py +++ b/addons/account_edi/models/account_move.py @@ -617,9 +617,9 @@ class AccountMove(models.Model): # Business operations #################################################### - def action_process_edi_web_services(self): + def action_process_edi_web_services(self, with_commit=True): docs = self.edi_document_ids.filtered(lambda d: d.state in ('to_send', 'to_cancel') and d.blocking_level != 'error') - docs._process_documents_web_services() + docs._process_documents_web_services(with_commit=with_commit) def _retry_edi_documents_error_hook(self): ''' Hook called when edi_documents are retried. For example, when it's needed to clean a field. diff --git a/addons/l10n_es_edi_sii/tests/test_edi_web_services.py b/addons/l10n_es_edi_sii/tests/test_edi_web_services.py index 03ef47c0d66..b9780c0eeb0 100644 --- a/addons/l10n_es_edi_sii/tests/test_edi_web_services.py +++ b/addons/l10n_es_edi_sii/tests/test_edi_web_services.py @@ -53,7 +53,7 @@ class TestEdiWebServices(TestEsEdiCommon): def test_edi_aeat(self): self.env.company.l10n_es_edi_tax_agency = 'aeat' - self.moves.action_process_edi_web_services() + self.moves.action_process_edi_web_services(with_commit=False) generated_files = self._process_documents_web_services(self.moves, {'es_sii'}) self.assertTrue(generated_files) self.assertRecordValues(self.out_invoice, [{'edi_state': 'sent'}]) @@ -62,7 +62,7 @@ class TestEdiWebServices(TestEsEdiCommon): def test_edi_gipuzkoa(self): self.env.company.l10n_es_edi_tax_agency = 'gipuzkoa' - self.moves.action_process_edi_web_services() + self.moves.action_process_edi_web_services(with_commit=False) generated_files = self._process_documents_web_services(self.moves, {'es_sii'}) self.assertTrue(generated_files) self.assertRecordValues(self.out_invoice, [{'edi_state': 'sent'}]) @@ -71,7 +71,7 @@ class TestEdiWebServices(TestEsEdiCommon): def test_edi_bizkaia(self): self.env.company.l10n_es_edi_tax_agency = 'bizkaia' - self.moves.action_process_edi_web_services() + self.moves.action_process_edi_web_services(with_commit=False) generated_files = self._process_documents_web_services(self.moves, {'es_sii'}) self.assertTrue(generated_files) self.assertRecordValues(self.out_invoice, [{'edi_state': 'sent'}])