diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-03-07 16:14:05 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 86a87aa8b0dde2237cfe1bb769724e8ed269b62e (patch) | |
| tree | 472de08242d81d1811c23dbfcd4381a903917d85 /addons/web/static/src/js/widgets | |
| parent | 78c97e6cc4c90036e68ad8f82b3c7d326b321067 (diff) | |
[REF] *: use _rpc method for all rpcs
The _rpc method is now the preferred method to do a rpc, so we need to
update all calls.
Diffstat (limited to 'addons/web/static/src/js/widgets')
5 files changed, 91 insertions, 63 deletions
diff --git a/addons/web/static/src/js/widgets/change_password.js b/addons/web/static/src/js/widgets/change_password.js index 56f9603a310..c1c9c4dddea 100644 --- a/addons/web/static/src/js/widgets/change_password.js +++ b/addons/web/static/src/js/widgets/change_password.js @@ -31,15 +31,18 @@ var ChangePassword = Widget.extend({ self.$el.parents('.modal').modal('hide'); }); $button.eq(0).click(function () { - self.performRPC('/web/session/change_password', { - fields: $('form[name=change_password_form]').serializeArray(), - }).done(function (result) { - if (result.error) { - self._display_error(result); - } else { - self.do_action('logout'); - } - }); + self._rpc('/web/session/change_password') + .params({ + fields: $('form[name=change_password_form]').serializeArray() + }) + .exec() + .done(function (result) { + if (result.error) { + self._display_error(result); + } else { + self.do_action('logout'); + } + }); }); }, diff --git a/addons/web/static/src/js/widgets/data_export.js b/addons/web/static/src/js/widgets/data_export.js index b4ae2023684..dbe4c4d3d3c 100644 --- a/addons/web/static/src/js/widgets/data_export.js +++ b/addons/web/static/src/js/widgets/data_export.js @@ -218,29 +218,32 @@ var DataExport = Dialog.extend({ this.$fields_list = this.$('.o_fields_list'); this.$import_compat_radios = this.$('.o_import_compat input'); - waitFor.push(this.rpc('/web/export/formats', {}).then(do_setup_export_formats)); + waitFor.push(this._rpc('/web/export/formats').exec().then(do_setup_export_formats)); var got_fields = new $.Deferred(); this.$import_compat_radios.change(function(e) { self.$('.o_field_tree_structure').remove(); - self.rpc("/web/export/get_fields", { - model: self.dataset.model, - import_compat: !!$(e.target).val(), - }).done(function (records) { - var compatible_fields = _.map(records, function (record) {return record.id}); - self.$fields_list - .find('option') - .filter(function () { - var option_field = $(this).attr('value'); - if (compatible_fields.indexOf(option_field) === -1) { - return true; - } - }) - .remove(); - got_fields.resolve(); - self.on_show_data(records); - }); + self._rpc("/web/export/get_fields") + .params({ + model: self.dataset.model, + import_compat: !!$(e.target).val(), + }) + .exec() + .done(function (records) { + var compatible_fields = _.map(records, function (record) {return record.id}); + self.$fields_list + .find('option') + .filter(function () { + var option_field = $(this).attr('value'); + if (compatible_fields.indexOf(option_field) === -1) { + return true; + } + }) + .remove(); + got_fields.resolve(); + self.on_show_data(records); + }); }).eq(0).change(); waitFor.push(got_fields); @@ -296,10 +299,13 @@ var DataExport = Dialog.extend({ self.$fields_list.empty(); var export_id = self.$('.o_exported_lists_select option:selected').val(); if(export_id) { - self.rpc('/web/export/namelist', { - model: self.dataset.model, - export_id: parseInt(export_id, 10), - }).then(do_load_export_field); + self._rpc('/web/export/namelist') + .params({ + model: self.dataset.model, + export_id: parseInt(export_id, 10), + }) + .exec() + .then(do_load_export_field); } }); self.$('.o_delete_exported_list').click(function() { @@ -341,17 +347,20 @@ var DataExport = Dialog.extend({ if(!record.loaded) { var self = this; - this.rpc("/web/export/get_fields", { - model: model, - prefix: prefix, - parent_name: name, - import_compat: !!this.$import_compat_radios.filter(':checked').val(), - parent_field_type : record['field_type'], - exclude: exclude_fields - }).done(function(results) { - record.loaded = true; - self.on_show_data(results, record.id); - }); + this._rpc("/web/export/get_fields") + .params({ + model: model, + prefix: prefix, + parent_name: name, + import_compat: !!this.$import_compat_radios.filter(':checked').val(), + parent_field_type : record['field_type'], + exclude: exclude_fields + }) + .exec() + .done(function(results) { + record.loaded = true; + self.on_show_data(results, record.id); + }); } else { this.show_content(record.id); } diff --git a/addons/web/static/src/js/widgets/debug_manager.js b/addons/web/static/src/js/widgets/debug_manager.js index 59becd8faea..697572257f8 100644 --- a/addons/web/static/src/js/widgets/debug_manager.js +++ b/addons/web/static/src/js/widgets/debug_manager.js @@ -63,9 +63,13 @@ var DebugManager = Widget.extend({ // whether the current user is an administrator this._is_admin = session.is_system; return $.when( - this.performModelRPC('res.users', 'check_access_rights', {operation: 'write', raise_exception: false}), + this._rpc('res.users', 'check_access_rights') + .kwargs({operation: 'write', raise_exception: false}) + .exec(), session.user_has_group('base.group_no_one'), - this.performModelRPC('ir.model.data', 'xmlid_to_res_id', {xmlid: 'base.group_no_one'}), + this._rpc('ir.model.data', 'xmlid_to_res_id') + .kwargs({xmlid: 'base.group_no_one'}) + .exec(), this._super() ).then(function (can_write_user, has_group_no_one, group_no_one_id) { this._features_group = can_write_user && group_no_one_id; @@ -161,7 +165,12 @@ var DebugManager = Widget.extend({ title: _t('Select a view'), disable_multiple_selection: true, on_selected: function (element_ids) { - self.performModelRPC('ir.ui.view', [[['id', '=', element_ids[0]]], ['name', 'model', 'type']], {limit: 1}).then(function (view) { + self._rpc('ir.ui.view', 'search_read') + .withDomain([['id', '=', element_ids[0]]]) + .withFields(['name', 'model', 'type']) + .withLimit(1) + .exec() + .then(function (view) { self.do_action({ type: 'ir.actions.act_window', name: view.name, @@ -219,16 +228,19 @@ DebugManager.include({ get_view_fields: function () { var self = this; var model = this._action.res_model; - this.performModelRPC(model, 'fields_get', [], { - attributes: ['string', 'searchable', 'required', 'readonly', 'type', 'store', 'sortable', 'relation', 'help'] - }).done(function (fields) { - new Dialog(self, { - title: _.str.sprintf(_t("Fields of %s"), model), - $content: $(QWeb.render('WebClient.DebugManager.Action.Fields', { - fields: fields - })) - }).open(); - }); + this._rpc(model, 'fields_get') + .kwargs({ + attributes: ['string', 'searchable', 'required', 'readonly', 'type', 'store', 'sortable', 'relation', 'help'] + }) + .exec() + .done(function (fields) { + new Dialog(self, { + title: _.str.sprintf(_t("Fields of %s"), model), + $content: $(QWeb.render('WebClient.DebugManager.Action.Fields', { + fields: fields + })) + }).open(); + }); }, manage_filters: function () { this.do_action({ @@ -254,8 +266,10 @@ DebugManager.include({ }); }, translate: function() { - var model = this._action.res_model; - this.performModelRPC("ir.translation", 'get_technical_translations', [model]).then(this.do_action); + this._rpc("ir.translation", 'get_technical_translations') + .args([this._action.res_model]) + .exec() + .then(this.do_action); } }); @@ -269,10 +283,12 @@ DebugManager.include({ this._can_edit_views = false; return $.when( this._super(), - this.performModelRPC('ir.ui.view', 'check_access_rights', {operation: 'write', raise_exception: false}) - .then(function (ar) { - this._can_edit_views = ar; - }.bind(this)) + this._rpc('ir.ui.view', 'check_access_rights') + .kwargs({operation: 'write', raise_exception: false}) + .exec() + .then(function (ar) { + this._can_edit_views = ar; + }.bind(this)) ); }, update: function (tag, descriptor, widget) { diff --git a/addons/web/static/src/js/widgets/model_field_selector.js b/addons/web/static/src/js/widgets/model_field_selector.js index a1fb3cc5c4b..41433253499 100644 --- a/addons/web/static/src/js/widgets/model_field_selector.js +++ b/addons/web/static/src/js/widgets/model_field_selector.js @@ -317,7 +317,7 @@ var ModelFieldSelector = Widget.extend({ _getModelFieldsFromCache: function (model, filters) { var def = modelFieldsCache.cacheDefs[model]; if (!def) { - def = modelFieldsCache.cacheDefs[model] = this.rpc(model, "fields_get") + def = modelFieldsCache.cacheDefs[model] = this._rpc(model, "fields_get") .args([ false, ["store", "searchable", "type", "string", "relation", "selection", "related"]]) diff --git a/addons/web/static/src/js/widgets/switch_company_menu.js b/addons/web/static/src/js/widgets/switch_company_menu.js index feaf487fcc7..1f5f0733938 100644 --- a/addons/web/static/src/js/widgets/switch_company_menu.js +++ b/addons/web/static/src/js/widgets/switch_company_menu.js @@ -18,7 +18,7 @@ var SwitchCompanyMenu = Widget.extend({ this.$el.on('click', '.dropdown-menu li a[data-menu]', _.debounce(function(ev) { ev.preventDefault(); var company_id = $(ev.currentTarget).data('company-id'); - self.rpc('res.users', 'write') + self._rpc('res.users', 'write') .args([[session.uid], {'company_id': company_id}]) .exec() .then(function() { |
