From 6bd3bae04e030f4d69457e121d4137361d2b557a Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 3 Jul 2017 13:53:26 +0200 Subject: [PATCH] [FIX] mass_mailing: domain translation As Admin: - Set up 2 languages for the installation, e.g. English and French - Admin language is English, Demo language is French - Create a `res.partner.category` named 'Test English' - Assign the category to a newly created partner - Create a French translation for 'Test English', e.g. 'Test Francais' As Demo: - Create a Mass Mailing - Select a custom domain: ('category_id', '=', 'Test Francais') => it should match one partner - Save and validate Now either: - manually run the scheduled action "Process Mass Mailing Queue" as Admin - wait for the cron to process the mass mailing No mail will be sent since the domain will be evaluated in the Admin language, i.e. English. Indeed, the domain `('category_id', '=', 'Test Francais')` does not match any record in English. The solution/workaround is to use the language of the last user who wrote on the mass mailing. Closes #20906, Closes #15467, Closes #15445 opw-778922 --- addons/mass_mailing/models/mass_mailing.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index c59f12da0e6..154acd47bd8 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -836,9 +836,12 @@ class MassMailing(osv.Model): for mass_mailing_id in mass_mailing_ids: mass_mailing_record = self.browse(cr, uid, mass_mailing_id, context=context) + _uid = mass_mailing_record.write_uid.id or uid + _context = self.pool.get("res.users").context_get(cr, _uid, context=context) + _context = dict(context or {}, **_context) - if len(self.get_remaining_recipients(cr, uid, mass_mailing_record, context=context)) > 0: - self.write(cr, uid, [mass_mailing_id], {'state': 'sending'}, context=context) - self.send_mail(cr, uid, [mass_mailing_id], context=context) + if len(self.get_remaining_recipients(cr, uid, mass_mailing_record, context=_context)) > 0: + self.write(cr, uid, [mass_mailing_id], {'state': 'sending'}, context=_context) + self.send_mail(cr, uid, [mass_mailing_id], context=_context) else: - self.write(cr, uid, [mass_mailing_id], {'state': 'done'}, context=context) + self.write(cr, uid, [mass_mailing_id], {'state': 'done'}, context=_context)