diff --git a/addons/account/wizard/account_invoice_send.py b/addons/account/wizard/account_invoice_send.py index 4c086fe6c8b4b6fde03cbeb62afe0880cd464268..9fe0ad5195e99ec07923e6dc65295397f226c695 100644 --- a/addons/account/wizard/account_invoice_send.py +++ b/addons/account/wizard/account_invoice_send.py @@ -140,15 +140,16 @@ class AccountInvoiceSend(models.TransientModel): if self.composition_mode == 'mass_mail' and self.template_id: active_ids = self.env.context.get('active_ids', self.res_id) active_records = self.env[self.model].browse(active_ids) - langs = active_records.mapped('partner_id.lang') - default_lang = get_lang(self.env) - for lang in (set(langs) or [default_lang]): + langs = set(active_records.mapped('partner_id.lang')) + for lang in langs: active_ids_lang = active_records.filtered(lambda r: r.partner_id.lang == lang).ids - self_lang = self.with_context(active_ids=active_ids_lang, lang=lang) + self_lang = self.with_context(active_ids=active_ids_lang, lang=get_lang(self.env, lang).code) self_lang.onchange_template_id() self_lang._send_email() else: - self._send_email() + active_record = self.env[self.model].browse(self.res_id) + lang = get_lang(self.env, active_record.partner_id.lang).code + self.with_context(lang=lang)._send_email() if self.is_print: return self._print_document() return {'type': 'ir.actions.act_window_close'}