summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2018-04-09 08:12:27 +0200
committerAdrian Torres <adt@odoo.com>2018-04-09 08:12:27 +0200
commitdc9525c3f02963ae5eb2ba97b671fa1f5fce9f72 (patch)
treec87d19c8462d4883229690ad4378d6bf5495ff85
parent9201f92a4f29a53a014b462469f27b32dca8fc5a (diff)
Revert "[IMP] mail: check if template can be rendered on write (#20834)"
This reverts commit a094095ef3c0be08adfaee69f9865465e3813d46. Context problems, see PR #20834
-rw-r--r--addons/mail/models/mail_template.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py
index 17cea52deac..211368f0f24 100644
--- a/addons/mail/models/mail_template.py
+++ b/addons/mail/models/mail_template.py
@@ -238,37 +238,6 @@ class MailTemplate(models.Model):
self.null_value = False
@api.multi
- def write(self, vals):
- # This override is for checking that the template is correct when
- # saving it
- if vals.get('body_html'):
- # render_template can return empty results if the mako rendering
- # crashes or if the body_html is empty, therefore we will only
- # perform this check if the new body_html is non-empty
- if vals.get('model_id'):
- _model = self.env['ir.model'].sudo().browse(
- vals['model_id']).model
- else:
- _model = self.model
-
- Model = self.env[_model]
- if not Model._abstract:
- # Get the latest record so as to not use older, potentially
- # deprecated/obsolete records
- res_ids = Model.search([], limit=1, order='id DESC').ids[:1]
- if res_ids:
- render = self.render_template(
- vals['body_html'], _model, res_ids)
-
- if not any(render.values()):
- raise UserError(_(
- "Template rendering failed, this could mean that "
- "your template contains python syntax errors"
- ))
-
- return super(MailTemplate, self).write(vals)
-
- @api.multi
def unlink(self):
self.unlink_action()
return super(MailTemplate, self).unlink()