From 7faa21c6a8b85b22a8ed9f719a194c82450cedfb Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 13 Oct 2016 12:35:09 +0200 Subject: [PATCH] [8.0][FIX][website_mail_snippet_fixed] Clean before saving. Before this patch, when a user dragged a fixed snippet on the email body, the result had some attributes that are internally used in Odoo to know if you are replacing a part of a view, and which. This made that editing the placeholders changed directly the snippet template itself. On other cases, when this addon was removed and then reinstalled, it made that previous templates raise a MissingError when saving any changes on them. Chances are that if you have (maybe unnoticedly) hit this bug, you have some snippet XMLID from this addon marked as `noupdate=1`, so the recommended upgrade path is to uninstall this addon and reinstall it. --- website_mail_snippet_fixed/__openerp__.py | 9 ++++--- .../static/src/js/fixed_560px.js | 26 +++++++++++++++++++ website_mail_snippet_fixed/views/assets.xml | 16 ++++++++++++ .../views/templates.xml | 8 +++++- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 website_mail_snippet_fixed/static/src/js/fixed_560px.js create mode 100644 website_mail_snippet_fixed/views/assets.xml diff --git a/website_mail_snippet_fixed/__openerp__.py b/website_mail_snippet_fixed/__openerp__.py index 5285e2b4..4bbbb296 100644 --- a/website_mail_snippet_fixed/__openerp__.py +++ b/website_mail_snippet_fixed/__openerp__.py @@ -4,10 +4,12 @@ { "name": "Fixed-Width Layout Snippets for Writing Emails", "summary": "560px width extra building blocks", - "version": "8.0.1.0.0", + "version": "8.0.1.0.1", "category": "Marketing", - "website": "http://www.antiun.com", - "author": "Antiun IngenierĂ­a S.L., Odoo Community Association (OCA)", + "website": "https://www.tecnativa.com", + "author": "Antiun IngenierĂ­a S.L., " + "Tecnativa, " + "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, @@ -18,6 +20,7 @@ "website_mail_snippet_vertical_resize_base", ], "data": [ + "views/assets.xml", "views/templates.xml", "views/snippet_1_col.xml", "views/snippet_2_cols.xml", diff --git a/website_mail_snippet_fixed/static/src/js/fixed_560px.js b/website_mail_snippet_fixed/static/src/js/fixed_560px.js new file mode 100644 index 00000000..070290ae --- /dev/null +++ b/website_mail_snippet_fixed/static/src/js/fixed_560px.js @@ -0,0 +1,26 @@ +/* Copyright 2016 Jairo Llopis + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ +(function ($) { + "use strict"; + openerp.website.snippet.options.fixed_560px = + openerp.website.snippet.Option.extend({ + // Remove attributes added by Odoo at drop time, to avoid him to try + // to overwrite the snippet view itself instead of just replacing the + // email/template body. + clean_for_save: function () { + this._super(); + var bad_attrs = [ + "data-oe-field", + "data-oe-id", + "data-oe-model", + "data-oe-source-id", + "data-oe-xpath", + "data-original-title", + ]; + for (var n in bad_attrs) { + var att = bad_attrs[n]; + this.$target.find("[" + att + "]").removeAttr(att); + } + }, + }); +})(jQuery); diff --git a/website_mail_snippet_fixed/views/assets.xml b/website_mail_snippet_fixed/views/assets.xml new file mode 100644 index 00000000..ca49d02d --- /dev/null +++ b/website_mail_snippet_fixed/views/assets.xml @@ -0,0 +1,16 @@ + + + + + + +