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()