diff --git a/static/src/js/website_form_editor.js b/static/src/js/website_form_editor.js index 49a6670006a..4dbde9f6615 100644 --- a/static/src/js/website_form_editor.js +++ b/static/src/js/website_form_editor.js @@ -60,23 +60,20 @@ odoo.define('website_form_editor', function (require) { fetch_model_fields: function() { var self = this; this.fields_deferred = new $.Deferred(); - this.performModelRPC("ir.model", "get_authorized_fields", - [ - this.$target.closest('form').attr('data-model_name') - ], - { - context: base.get_context() - } - ).then(function(fields) { - // The get_fields function doesn't return the name - // in the field dict since it uses it has the key - _.map(fields, function(field, field_name){ - field.name = field_name; - return field; - }); + this.rpc("ir.model", "get_authorized_fields") + .args([this.$target.closest('form').attr('data-model_name')]) + .withContext(base.get_context()) + .exec() + .then(function(fields) { + // The get_fields function doesn't return the name + // in the field dict since it uses it has the key + _.map(fields, function(field, field_name){ + field.name = field_name; + return field; + }); - self.fields_deferred.resolve(fields) - }); + self.fields_deferred.resolve(fields) + }); return this.fields_deferred; }, @@ -86,73 +83,72 @@ odoo.define('website_form_editor', function (require) { if (type !== 'click') return; var self = this; - this.performModelRPC("ir.model", "search_read", - [ + this.rpc("ir.model", "search_read") + .args([ [['website_form_access', '=', true]], ['id', 'model', 'name', 'website_form_label'] - ], - { - context: base.get_context() - } - ).then(function(models) { - // Models selection input - var model_selection = qweb.render("website_form_editor.field_many2one", { - field: { - name: 'model_selection', - string: 'Action', - records: _.map(models, function(m){ - return { - id: m.model, - display_name: m.website_form_label || m.name, - selected: (m.model == self.$target.attr('data-model_name')) ? 1: null - } - }) - } - }); - - // Success page input - var success_page = qweb.render("website_form_editor.field_char", { - field: { - name: 'success_page', - string: 'Thank You Page', - value: self.$target.attr('data-success_page') - } - }); - - // Form parameters modal - self.build_modal( - "Form Parameters", - model_selection + success_page, - function(){ - var model_name = self.$modal.find("[name='model_selection']").val(); - var success_page = self.$modal.find("[name='success_page']").val(); - self.init_form(model_name); - self.$target.attr('data-success_page', success_page); - - // Add magic email_to input if model is mail.mail - self.$target.find("input.form-field[name='email_to']").remove(); - if (model_name == 'mail.mail') { - var email_to = self.$modal.find("input[name='email_to']").val(); - self.$target.append(""); + ]) + .withContext(base.get_context()) + .exec() + .then(function(models) { + // Models selection input + var model_selection = qweb.render("website_form_editor.field_many2one", { + field: { + name: 'model_selection', + string: 'Action', + records: _.map(models, function(m){ + return { + id: m.model, + display_name: m.website_form_label || m.name, + selected: (m.model == self.$target.attr('data-model_name')) ? 1: null + } + }) } - } - ); + }); - self.toggle_email_to(); + // Success page input + var success_page = qweb.render("website_form_editor.field_char", { + field: { + name: 'success_page', + string: 'Thank You Page', + value: self.$target.attr('data-success_page') + } + }); + + // Form parameters modal + self.build_modal( + "Form Parameters", + model_selection + success_page, + function(){ + var model_name = self.$modal.find("[name='model_selection']").val(); + var success_page = self.$modal.find("[name='success_page']").val(); + self.init_form(model_name); + self.$target.attr('data-success_page', success_page); + + // Add magic email_to input if model is mail.mail + self.$target.find("input.form-field[name='email_to']").remove(); + if (model_name == 'mail.mail') { + var email_to = self.$modal.find("input[name='email_to']").val(); + self.$target.append(""); + } + } + ); - self.$modal.find("[name='model_selection']").on('change', function() { self.toggle_email_to(); - }); - // On modal close, if there is no data-model, it means - // that the user refused to configure the form on the - // first modal, so we remove the snippet. - self.$modal.on('hidden.bs.modal', function (e) { - if (!self.$target.attr('data-model_name')){ - self.$target.remove(); - } + self.$modal.find("[name='model_selection']").on('change', function() { + self.toggle_email_to(); + }); + + // On modal close, if there is no data-model, it means + // that the user refused to configure the form on the + // first modal, so we remove the snippet. + self.$modal.on('hidden.bs.modal', function (e) { + if (!self.$target.attr('data-model_name')){ + self.$target.remove(); + } + }); }); - }) }, // Choose a field modal @@ -345,7 +341,9 @@ odoo.define('website_form_editor', function (require) { if (fields.length) { // ideally we'd only do this if saving the form // succeeds... but no idea how to do that - this.performModelRPC('ir.model.fields', 'formbuilder_whitelist', [model, _.uniq(fields)]); + this.rpc('ir.model.fields', 'formbuilder_whitelist') + .args([model, _.uniq(fields)]) + .exec(); } } diff --git a/static/src/js/website_form_editor_tour.js b/static/src/js/website_form_editor_tour.js index 68e8182eafb..6a3dc2152c8 100644 --- a/static/src/js/website_form_editor_tour.js +++ b/static/src/js/website_form_editor_tour.js @@ -601,8 +601,8 @@ odoo.define('website_form_editor.tour', function(require) { content: "Check mail.mail records have been created", trigger: "body", run: function () { - var mailDef = this.performModelRPC("mail.mail", "search_read", - [ + var mailDef = this.rpc("mail.mail", "search_read") + .args([ // TODO: add other fields in domain ! [ ['email_to', '=', 'test@test.test'], @@ -612,8 +612,8 @@ odoo.define('website_form_editor.tour', function(require) { ['body_html', 'like', 'Products : Xperia,Wiko Stairway'] ], [] - ] - ); + ]) + .exec(); var success = function(model, data) { if(data.length) { $('body').append('
');