From 1d50d8c9457cce56a369d922b9de9b0ee37fd433 Mon Sep 17 00:00:00 2001 From: "Nasreddin Boulif (bon)" <bon@odoo.com> Date: Thu, 31 Aug 2023 13:02:31 +0200 Subject: [PATCH] [FIX] account: send invoice mail in partner language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce: - Install `account` module - Activate another language (e.g. French) - Create a partner with the new activated language - Create an invoice for this partner and sent it by mail Issue: Some words in the external layout of the email are not translated; button and title Cause: The language of the partner is not taken into account (except for the model name in the button) when creating the external layout of the mail. Solution: Call send_mail with the partner language in the context. opw-3301607 closes odoo/odoo#133744 Signed-off-by: William André (wan) <wan@odoo.com> --- addons/account/wizard/account_invoice_send.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/account/wizard/account_invoice_send.py b/addons/account/wizard/account_invoice_send.py index 4c086fe6c8b4..9fe0ad5195e9 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'} -- GitLab