summaryrefslogtreecommitdiff
path: root/addons/sms
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-04-05 09:21:18 +0000
committerThibault Delavallée <tde@odoo.com>2020-03-24 10:24:16 +0000
commitaa31e67716f19ad84145ecb35b0cda07e2143b83 (patch)
tree15f5f6af219acf0d65c63f72a457ff501f94f4ae /addons/sms
parent6e25a510b3b44cbdd5844b224cc90eb6108853fb (diff)
[REF] mail, sms: reorganize {mail.sms}.template and mail.render.mixin fields and add docstrings
PURPOSE Clarify mail.template, mail.render.mixin and sms.template code organization. SPECIFICATIONS Reorganize fields according to their main use. Remove an unnecessary onchange in mail template model. As "model" field on mail template is a computed field its computation is sufficient. Add some docstrings and code separations. Prepare future code change. LINKS Task ID 1963529 Community PR odoo/odoo#32397
Diffstat (limited to 'addons/sms')
-rw-r--r--addons/sms/models/sms_template.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/addons/sms/models/sms_template.py b/addons/sms/models/sms_template.py
index d09dd26a703..46c8841dc2a 100644
--- a/addons/sms/models/sms_template.py
+++ b/addons/sms/models/sms_template.py
@@ -38,6 +38,10 @@ class SMSTemplate(models.Model):
name=_("%s (copy)") % self.name)
return super(SMSTemplate, self).copy(default=default)
+ def unlink(self):
+ self.sudo().mapped('sidebar_action_id').unlink()
+ return super(SMSTemplate, self).unlink()
+
def action_create_sidebar_action(self):
ActWindow = self.env['ir.actions.act_window']
view = self.env.ref('sms.sms_composer_view_form')
@@ -64,6 +68,10 @@ class SMSTemplate(models.Model):
template.sidebar_action_id.unlink()
return True
+ # ------------------------------------------------------------
+ # RENDERING
+ # ------------------------------------------------------------
+
def _get_context_lang_per_id(self, res_ids):
self.ensure_one()
if res_ids is None:
@@ -74,7 +82,8 @@ class SMSTemplate(models.Model):
results = dict((res_id, self.with_context(lang=lang)) for res_id in res_ids)
else:
rendered_langs = self._render_template(self.lang, self.model, res_ids)
- results = dict((res_id, self.with_context(lang=lang) if lang else self)
+ results = dict(
+ (res_id, self.with_context(lang=lang) if lang else self)
for res_id, lang in rendered_langs.items())
return results
@@ -103,7 +112,3 @@ class SMSTemplate(models.Model):
def _render_template(self, template_txt, model, res_ids):
""" Render the jinja template """
return self.env['mail.template']._render_template(template_txt, model, res_ids)
-
- def unlink(self):
- self.sudo().mapped('sidebar_action_id').unlink()
- return super(SMSTemplate, self).unlink()