summaryrefslogtreecommitdiff
path: root/addons/sms/wizard
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-03-06 13:17:20 +0000
committerThibault Delavallée <tde@odoo.com>2020-03-24 10:24:42 +0000
commit2835e0ba38f67f76b7f43948290050dcc68cd9db (patch)
tree369ae761539aca4cef909656cfd6e63b6d56af0c /addons/sms/wizard
parent822f468059c9702b0898016e7bfbaf036a2c4036 (diff)
[MOV] mail, sms: move language computation in render mixin directly
PURPOSE Merge rendering tools used in mail and sms templates as well as partially in mailings and move them directly in mail.render.mixin. SPECIFICATIONS Move tools related to language computation from mail.template model to the mail.render.mixin. It allows to update both * mail.template: simply update calls accordingly; * sms.template: remove code doing what is now available through mail.render .mixin inherit; Lang field is moved to mail.render.mixin as it is used notably for the language computation. It therefore adds the field on mailing.mailing model although not used currently. LINKS Task ID 1963529 Community PR odoo/odoo#32397
Diffstat (limited to 'addons/sms/wizard')
-rw-r--r--addons/sms/wizard/sms_composer.py4
-rw-r--r--addons/sms/wizard/sms_template_preview.py7
2 files changed, 6 insertions, 5 deletions
diff --git a/addons/sms/wizard/sms_composer.py b/addons/sms/wizard/sms_composer.py
index 60c915d8172..7d5cbc9bfd2 100644
--- a/addons/sms/wizard/sms_composer.py
+++ b/addons/sms/wizard/sms_composer.py
@@ -168,7 +168,7 @@ class SendSMS(models.TransientModel):
@api.onchange('composition_mode', 'res_model', 'res_id', 'template_id')
def _onchange_template_id(self):
if self.template_id and self.composition_mode == 'comment' and self.res_id:
- self.body = self.template_id._get_translated_bodies([self.res_id])[self.res_id]
+ self.body = self.template_id._render_field('body', [self.res_id], compute_lang=True)[self.res_id]
elif self.template_id:
self.body = self.template_id.body
@@ -279,7 +279,7 @@ class SendSMS(models.TransientModel):
def _prepare_body_values(self, records):
if self.template_id and self.body == self.template_id.body:
- all_bodies = self.template_id._get_translated_bodies(records.ids)
+ all_bodies = self.template_id._render_field('body', records.ids, compute_lang=True)
else:
all_bodies = self.env['mail.render.mixin']._render_template(self.body, records._name, records.ids)
return all_bodies
diff --git a/addons/sms/wizard/sms_template_preview.py b/addons/sms/wizard/sms_template_preview.py
index 9d00185ee2e..837c0b821b8 100644
--- a/addons/sms/wizard/sms_template_preview.py
+++ b/addons/sms/wizard/sms_template_preview.py
@@ -45,6 +45,7 @@ class SMSTemplatePreview(models.TransientModel):
@api.depends('lang', 'resource_ref')
def _compute_sms_template_fields(self):
for wizard in self:
- # Update body depending of the resource_ref
- sms_template = wizard.sms_template_id.with_context(lang=wizard.lang)
- wizard.body = sms_template._render_template(sms_template.body, sms_template.model, wizard.resource_ref.id) if wizard.resource_ref else sms_template.body
+ if wizard.sms_template_id and wizard.resource_ref:
+ wizard.body = wizard.sms_template_id._render_field('body', [wizard.resource_ref.id], set_lang=wizard.lang)[wizard.resource_ref.id]
+ else:
+ wizard.body = wizard.sms_template_id.body