From dc9525c3f02963ae5eb2ba97b671fa1f5fce9f72 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Mon, 9 Apr 2018 08:12:27 +0200 Subject: [PATCH] Revert "[IMP] mail: check if template can be rendered on write (#20834)" This reverts commit a094095ef3c0be08adfaee69f9865465e3813d46. Context problems, see PR #20834 --- addons/mail/models/mail_template.py | 31 ----------------------------- 1 file changed, 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 @@ -237,37 +237,6 @@ class MailTemplate(models.Model): self.sub_model_object_field = False 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()