[FIX] mail: fix activity notification language
Issue - Install CRM, Discuss - Have 2 languages (e.g. french english) - User 1 > French - User 2 > English - Create an activity as user 1 for user 2 - As user 2, check discuss > history Notification received in french Cause mail_activity action_notify method uses the context language which is the active user language. Solution If user 2 has a language set, use this language for translating body template (self) and activity type (activity) OPW-2205409 closes odoo/odoo#46800 X-original-commit: ccfe573b4eee82de92d130addb745f68b3fd3bd9 Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
This commit is contained in:
@@ -384,8 +384,14 @@ class MailActivity(models.Model):
|
||||
def action_notify(self):
|
||||
if not self:
|
||||
return
|
||||
original_context = self.env.context
|
||||
body_template = self.env.ref('mail.message_activity_assigned')
|
||||
for activity in self:
|
||||
if activity.user_id.lang:
|
||||
# Send the notification in the assigned user's language
|
||||
self = self.with_context(lang=activity.user_id.lang)
|
||||
body_template = body_template.with_context(lang=activity.user_id.lang)
|
||||
activity = activity.with_context(lang=activity.user_id.lang)
|
||||
model_description = self.env['ir.model']._get(activity.res_model).display_name
|
||||
body = body_template.render(
|
||||
dict(
|
||||
@@ -406,6 +412,8 @@ class MailActivity(models.Model):
|
||||
model_description=model_description,
|
||||
email_layout_xmlid='mail.mail_notification_light',
|
||||
)
|
||||
body_template = body_template.with_context(original_context)
|
||||
self = self.with_context(original_context)
|
||||
|
||||
def action_done(self):
|
||||
""" Wrapper without feedback because web button add context as
|
||||
|
||||
Reference in New Issue
Block a user