diff --git a/account_invoice_mass_sending/models/account_move.py b/account_invoice_mass_sending/models/account_move.py index f7c70fedcc4..b073f7b1121 100644 --- a/account_invoice_mass_sending/models/account_move.py +++ b/account_invoice_mass_sending/models/account_move.py @@ -43,6 +43,7 @@ def _send_invoice_individually(self, template=None): { "active_model": self._name, "active_ids": self.ids, + "account_invoice_mass_sending": True, } ) wiz = self.env["account.invoice.send"].with_context(**wiz_ctx).create({}) diff --git a/account_invoice_mass_sending/wizards/account_invoice_send.py b/account_invoice_mass_sending/wizards/account_invoice_send.py index 986150d9c93..428d1a44908 100644 --- a/account_invoice_mass_sending/wizards/account_invoice_send.py +++ b/account_invoice_mass_sending/wizards/account_invoice_send.py @@ -1,6 +1,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, models +from odoo import _, api, models class AccountInvoiceSend(models.TransientModel): @@ -48,3 +48,12 @@ def enqueue_invoices(self): } ) return notification + + @api.onchange("invoice_ids") + def _compute_composition_mode(self): + """Force send as mass_mail although this module sends each invoice one by one + to avoid extra notificactions""" + if not self.env.context.get("account_invoice_mass_sending", False): + return super()._compute_composition_mode() + for wizard in self: + wizard.composer_id.composition_mode = "mass_mail"