From ead78e5c2c3dd05a05ec3d8d8109a56f49fa2970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sun, 5 Mar 2017 20:57:23 +0100 Subject: [PATCH] [FIX] website_form_editor: correct ajax rpc calls The website_form_editor code was adapted to the new rpc methods, but this concerns class that do not have the rpc method. We use the callback argument to specify a given ajax method --- static/src/js/website_form_editor.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/static/src/js/website_form_editor.js b/static/src/js/website_form_editor.js index 4dbde9f6615..9b18f44db27 100644 --- a/static/src/js/website_form_editor.js +++ b/static/src/js/website_form_editor.js @@ -3,6 +3,7 @@ odoo.define('website_form_editor', function (require) { var core = require('web.core'); var ajax = require('web.ajax'); + var rpc = require('web.rpc'); var base = require('web_editor.base'); var options = require('web_editor.snippets.options'); @@ -60,10 +61,10 @@ odoo.define('website_form_editor', function (require) { fetch_model_fields: function() { var self = this; this.fields_deferred = new $.Deferred(); - this.rpc("ir.model", "get_authorized_fields") + rpc.query({model: "ir.model", method: "get_authorized_fields"}) .args([this.$target.closest('form').attr('data-model_name')]) .withContext(base.get_context()) - .exec() + .exec({callback: ajax.rpc.bind(ajax)}) .then(function(fields) { // The get_fields function doesn't return the name // in the field dict since it uses it has the key @@ -83,13 +84,13 @@ odoo.define('website_form_editor', function (require) { if (type !== 'click') return; var self = this; - this.rpc("ir.model", "search_read") + rpc.query({model: "ir.model", method: "search_read"}) .args([ [['website_form_access', '=', true]], ['id', 'model', 'name', 'website_form_label'] ]) .withContext(base.get_context()) - .exec() + .exec({callback: ajax.rpc.bind(ajax)}) .then(function(models) { // Models selection input var model_selection = qweb.render("website_form_editor.field_many2one", { @@ -341,9 +342,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.rpc('ir.model.fields', 'formbuilder_whitelist') + rpc.query({model: 'ir.model.fields', method: 'formbuilder_whitelist'}) .args([model, _.uniq(fields)]) - .exec(); + .exec({callback: ajax.rpc.bind(ajax)}); } }