From e3ae92e35c7f62ebfc1003f1e7f560a850ef8e5d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 14 Sep 2017 13:28:18 +0200 Subject: [PATCH] [FIX] website_form_editor: don't duplicate email_to field website_form_editor does not depend on project but apparently just assumes it's been installed and the form construction tour uses it to change the "action" selection to issues then (back to?) sending an email. This ends up triggering two additional "change" events on the email option, which adds a new email_to field every time, blocks the submission of the form (since they're all required and only one is filled) and breaks the tour. On "toggle_email_to", only add an email_to field if it's not already present. --- static/src/js/website_form_editor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/src/js/website_form_editor.js b/static/src/js/website_form_editor.js index 80a9e8d67e0..b507179cc2a 100644 --- a/static/src/js/website_form_editor.js +++ b/static/src/js/website_form_editor.js @@ -269,9 +269,10 @@ odoo.define('website_form_editor', function (require) { toggle_email_to: function() { // Display or remove the magic email_to field for model mail.mail var selected_model_name = this.$modal.find("[name='model_selection']").val(); - if (selected_model_name != 'mail.mail') { - this.$modal.find(".form-field:has(input[name='email_to'])").remove(); - } else { + var $current = this.$modal.find(".form-field:has(input[name='email_to'])"); + if (selected_model_name !== 'mail.mail') { + $current.remove(); + } else if (!$current.length) { // only add field if it's not already here this.$modal.find("form").append( // Email To input $(qweb.render("website_form_editor.field_char", {