[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.
This commit is contained in:
Xavier Morel
2017-09-14 13:28:18 +02:00
parent 1085fdd8be
commit c216ccda98
+3 -2
View File
@@ -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", {