From 6af55b6afb17e08d7b03be644abfa1f9db708736 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Mon, 12 Jun 2023 07:25:07 +0000 Subject: [PATCH] [FIX] account_peppol: commit after updating the move When using the Send & Print wizard in invoice_single, the error is raised if any making all changes rollbacked including the update of the 'peppol_move_state'. closes odoo/odoo#125302 X-original-commit: ec1209c2853ead82bcf27728612d1a7efc6dc97a Signed-off-by: Laurent Smet --- addons/account/wizard/account_move_send.py | 10 +++++++++- addons/account_peppol/wizard/account_move_send.py | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/account/wizard/account_move_send.py b/addons/account/wizard/account_move_send.py index 993baa660dd..265172cae4b 100644 --- a/addons/account/wizard/account_move_send.py +++ b/addons/account/wizard/account_move_send.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from odoo import _, api, fields, models, tools, Command +from odoo import _, api, fields, models, modules, tools, Command from odoo.exceptions import UserError from odoo.tools.misc import get_lang @@ -483,6 +483,14 @@ class AccountMoveSend(models.Model): **mail_params, ) + def _can_commit(self): + """ Helper to know if we can commit the current transaction or not. + + :return: True if commit is accepted, False otherwise. + """ + self.ensure_one() + return not tools.config['test_enable'] and not modules.module.current_test + def _call_web_service(self, invoices_data): # TO OVERRIDE self.ensure_one() diff --git a/addons/account_peppol/wizard/account_move_send.py b/addons/account_peppol/wizard/account_move_send.py index f786d835c81..9ca113c0bed 100644 --- a/addons/account_peppol/wizard/account_move_send.py +++ b/addons/account_peppol/wizard/account_move_send.py @@ -178,3 +178,6 @@ class AccountMoveSend(models.Model): invoices |= invoice log_message = _('The document has been sent to the Peppol Access Point for processing') invoices._message_log_batch(bodies=dict((invoice.id, log_message) for invoice in invoices_data_peppol)) + + if self._can_commit(): + self._cr.commit()