[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 <las@odoo.com>
Signed-off-by: Stanislas Gueniffey (stgu) <stgu@odoo.com>
This commit is contained in:
Stanislas Gueniffey
2022-05-06 13:30:04 +02:00
parent c7cefee9cf
commit 5d323574ec
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -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.
@@ -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'}])