From c216ccda98d57ee6588cccd4c0ff3cb4074a43b8 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/src/js/website_form_editor.js b/static/src/js/website_form_editor.js index 4746efd7de9..3523126edcd 100644 --- a/static/src/js/website_form_editor.js +++ b/static/src/js/website_form_editor.js @@ -247,9 +247,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(); + var $current = this.$modal.find(".form-field:has(input[name='email_to'])"); if (selected_model_name !== 'mail.mail') { - this.$modal.find(".form-field:has(input[name='email_to'])").remove(); - } else { + $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", {