summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js176
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_controller.js42
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_model.js44
-rw-r--r--addons/web/static/src/js/views/pivot/pivot_model.js28
-rw-r--r--addons/web/static/src/js/widgets/model_field_selector.js14
-rw-r--r--addons/web/static/src/js/widgets/switch_company_menu.js9
6 files changed, 163 insertions, 150 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 51760a3c3b8..e150405e3e3 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -267,68 +267,74 @@ var FieldMany2One = AbstractField.extend({
domain.push(['id', 'not in', blacklisted_ids]);
}
- this.performModelRPC(this.field.relation, "name_search", [], {
- name: search_val,
- args: domain,
- operator: "ilike",
- limit: this.limit + 1,
- context: context,
- }).then(function (result) {
- // possible selections for the m2o
- var values = _.map(result, function (x) {
- x[1] = x[1].split("\n")[0];
- return {
- label: _.str.escapeHTML(x[1].trim()) || data.noDisplayContent,
- value: x[1],
- name: x[1],
- id: x[0],
- };
- });
-
- // search more... if more results than limit
- if (values.length > self.limit) {
- values = values.slice(0, self.limit);
- values.push({
- label: _t("Search More..."),
- action: function () {
- self.performModelRPC(self.field.relation, "name_search", {
- name: search_val,
- args: domain,
- operator: "ilike",
- limit: 160,
- context: context,
- }).then(self._searchCreatePopup.bind(self, "search"));
- },
- classname: 'o_m2o_dropdown_option',
- });
- }
- var create_enabled = self.can_create && !self.nodeOptions.no_create;
- // quick create
- var raw_result = _.map(result, function (x) { return x[1]; });
- if (create_enabled && !self.nodeOptions.no_quick_create &&
- search_val.length > 0 && !_.contains(raw_result, search_val)) {
- values.push({
- label: _.str.sprintf(_t('Create "<strong>%s</strong>"'),
- $('<span />').text(search_val).html()),
- action: self._quickCreate.bind(self, search_val),
- classname: 'o_m2o_dropdown_option'
- });
- }
- // create and edit ...
- if (create_enabled && !self.nodeOptions.no_create_edit) {
- values.push({
- label: _t("Create and Edit..."),
- action: self._searchCreatePopup.bind(self, "form", false, self._createContext(search_val)),
- classname: 'o_m2o_dropdown_option',
- });
- } else if (values.length === 0) {
- values.push({
- label: _t("No results to show..."),
+ this.rpc(this.field.relation, "name_search")
+ .kwargs({
+ name: search_val,
+ args: domain,
+ operator: "ilike",
+ limit: this.limit + 1,
+ context: context,
+ })
+ .exec()
+ .then(function (result) {
+ // possible selections for the m2o
+ var values = _.map(result, function (x) {
+ x[1] = x[1].split("\n")[0];
+ return {
+ label: _.str.escapeHTML(x[1].trim()) || data.noDisplayContent,
+ value: x[1],
+ name: x[1],
+ id: x[0],
+ };
});
- }
- def.resolve(values);
- });
+ // search more... if more results than limit
+ if (values.length > self.limit) {
+ values = values.slice(0, self.limit);
+ values.push({
+ label: _t("Search More..."),
+ action: function () {
+ self.rpc(self.field.relation, "name_search")
+ .kwargs({
+ name: search_val,
+ args: domain,
+ operator: "ilike",
+ limit: 160,
+ context: context,
+ })
+ .exec()
+ .then(self._searchCreatePopup.bind(self, "search"));
+ },
+ classname: 'o_m2o_dropdown_option',
+ });
+ }
+ var create_enabled = self.can_create && !self.nodeOptions.no_create;
+ // quick create
+ var raw_result = _.map(result, function (x) { return x[1]; });
+ if (create_enabled && !self.nodeOptions.no_quick_create &&
+ search_val.length > 0 && !_.contains(raw_result, search_val)) {
+ values.push({
+ label: _.str.sprintf(_t('Create "<strong>%s</strong>"'),
+ $('<span />').text(search_val).html()),
+ action: self._quickCreate.bind(self, search_val),
+ classname: 'o_m2o_dropdown_option'
+ });
+ }
+ // create and edit ...
+ if (create_enabled && !self.nodeOptions.no_create_edit) {
+ values.push({
+ label: _t("Create and Edit..."),
+ action: self._searchCreatePopup.bind(self, "form", false, self._createContext(search_val)),
+ classname: 'o_m2o_dropdown_option',
+ });
+ } else if (values.length === 0) {
+ values.push({
+ label: _t("No results to show..."),
+ });
+ }
+
+ def.resolve(values);
+ });
return def;
},
@@ -379,13 +385,13 @@ var FieldMany2One = AbstractField.extend({
if (this.mode === 'readonly' && !this.nodeOptions.no_open) {
event.preventDefault();
event.stopPropagation();
- this.performModelRPC(this.field.relation, 'get_formview_action', [
- [this.value.res_id]
- ], {
- context: this.record.getContext({fieldName: this.name}),
- }).then(function (action) {
- self.trigger_up('do_action', {action: action});
- });
+ this.rpc(this.field.relation, 'get_formview_action')
+ .args([[this.value.res_id]])
+ .withContext(this.record.getContext({fieldName: this.name}))
+ .exec()
+ .then(function (action) {
+ self.trigger_up('do_action', {action: action});
+ });
}
},
/**
@@ -397,26 +403,24 @@ var FieldMany2One = AbstractField.extend({
return;
}
var self = this;
- var model = this.field.relation;
- var method = 'get_formview_id';
var context = this.record.getContext({fieldName: this.name});
- this.performModelRPC(model, method, [
- [this.value.res_id]
- ], {
- context: context,
- }).then(function (view_id) {
- new dialogs.FormViewDialog(self, {
- res_model: self.field.relation,
- res_id: self.value.res_id,
- context: context,
- title: _t("Open: ") + self.string,
- view_id: view_id,
- readonly: !self.can_write,
- on_saved: function () {
- self.trigger_up('reload', {db_id: self.value.id});
- },
- }).open();
- });
+ this.rpc(this.field.relation, 'get_formview_id')
+ .args([[this.value.res_id]])
+ .withContext(context)
+ .exec()
+ .then(function (view_id) {
+ new dialogs.FormViewDialog(self, {
+ res_model: self.field.relation,
+ res_id: self.value.res_id,
+ context: context,
+ title: _t("Open: ") + self.string,
+ view_id: view_id,
+ readonly: !self.can_write,
+ on_saved: function () {
+ self.trigger_up('reload', {db_id: self.value.id});
+ },
+ }).open();
+ });
},
/**
* @private
diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js
index b8010c97899..83fbbf3a4bf 100644
--- a/addons/web/static/src/js/views/kanban/kanban_controller.js
+++ b/addons/web/static/src/js/views/kanban/kanban_controller.js
@@ -300,26 +300,28 @@ var KanbanController = BasicController.extend({
}
data.context['default_' + data.groupedBy[0]] = column.id;
- this.performModelRPC(data.model, "name_create", [event.data.value], {
- context: data.context,
- }).then(
- add_record,
- function (event) {
- event.preventDefault();
- var popup = new form_common.SelectCreatePopup(this);
- popup.select_element(
- data.model,
- {
- title: _t("Create: "),
- initial_view: "form",
- disable_multiple_selection: true,
- },
- [],
- { default_name: event.data.value }
- );
- popup.on("elements_selected", null, add_record);
- }
- );
+ this.rpc(data.model, "name_create")
+ .args([event.data.value])
+ .withContext(data.context)
+ .exec()
+ .then(
+ add_record,
+ function (event) {
+ event.preventDefault();
+ var popup = new form_common.SelectCreatePopup(this);
+ popup.select_element(
+ data.model,
+ {
+ title: _t("Create: "),
+ initial_view: "form",
+ disable_multiple_selection: true,
+ },
+ [],
+ { default_name: event.data.value }
+ );
+ popup.on("elements_selected", null, add_record);
+ }
+ );
},
/**
* @param {OdooEvent} event
diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js
index 8970343c3a9..1448ea35ca7 100644
--- a/addons/web/static/src/js/views/kanban/kanban_model.js
+++ b/addons/web/static/src/js/views/kanban/kanban_model.js
@@ -98,28 +98,30 @@ return BasicModel.extend({
if (!groupByField || groupByField.type !== 'many2one') {
return $.Deferred().reject(); // only supported when grouped on m2o
}
- return this.performModelRPC(groupByField.relation, 'name_create', [name], {
- context: parent.context, // todo: combine with view context
- }).then(function (result) {
- var newGroup = self._makeDataPoint({
- modelName: parent.model,
- context: parent.context,
- domain: parent.domain.concat([[groupBy,"=",result[0]]]),
- fields: parent.fields,
- fieldNames: parent.fieldNames,
- groupedBy: parent.groupedBy,
- isOpen: true,
- limit: parent.limit,
- openGroupByDefault: true,
- orderedBy: parent.orderedBy,
- value: result,
- });
+ return this.rpc(groupByField.relation, 'name_create')
+ .args([name])
+ .withContext(parent.context) // todo: combine with view context
+ .exec()
+ .then(function (result) {
+ var newGroup = self._makeDataPoint({
+ modelName: parent.model,
+ context: parent.context,
+ domain: parent.domain.concat([[groupBy,"=",result[0]]]),
+ fields: parent.fields,
+ fieldNames: parent.fieldNames,
+ groupedBy: parent.groupedBy,
+ isOpen: true,
+ limit: parent.limit,
+ openGroupByDefault: true,
+ orderedBy: parent.orderedBy,
+ value: result,
+ });
- // newGroup.is_open = true;
- parent.data.push(newGroup.id);
- parent.count++;
- return newGroup.id;
- });
+ // newGroup.is_open = true;
+ parent.data.push(newGroup.id);
+ parent.count++;
+ return newGroup.id;
+ });
},
});
diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js
index cd203c22d35..8683a6adbce 100644
--- a/addons/web/static/src/js/views/pivot/pivot_model.js
+++ b/addons/web/static/src/js/views/pivot/pivot_model.js
@@ -82,13 +82,13 @@ var PivotModel = AbstractModel.extend({
}
return $.when.apply(null, groupbys.map(function (groupBy) {
- return self.performModelRPC(self.modelName, 'read_group', [], {
- context: self.data.context,
- domain: header.domain.length ? header.domain : self.data.domain,
- fields: _.map(fields, function (field) { return field.split(':')[0]; }),
- groupby: groupBy,
- lazy: false,
- });
+ return self.rpc(self.modelName, 'read_group')
+ .withContext(self.data.context)
+ .withDomain(header.domain.length ? header.domain : self.data.domain)
+ .withFields(_.map(fields, function (field) { return field.split(':')[0]; }))
+ .groupBy(groupBy)
+ .lazy(false)
+ .exec();
})).then(function () {
var data = Array.prototype.slice.call(arguments);
var datapt, attrs, j, l, row, col, cell_value, groupBys;
@@ -513,13 +513,13 @@ var PivotModel = AbstractModel.extend({
}
return $.when.apply(null, groupBys.map(function (groupBy) {
- return self.performModelRPC(self.modelName, 'read_group', [], {
- context: self.data.context,
- domain: self.data.domain,
- fields: _.map(fields, function (field) { return field.split(':')[0]; }),
- groupby: groupBy,
- lazy: false,
- });
+ return self.rpc(self.modelName, 'read_group')
+ .withContext(self.data.context)
+ .withDomain(self.data.domain)
+ .withFields(_.map(fields, function (field) { return field.split(':')[0]; }))
+ .groupBy(groupBy)
+ .lazy(false)
+ .exec();
})).then(function () {
var data = Array.prototype.slice.call(arguments);
if (data[0][0].__count === 0) {
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 9c843937c90..a1fb3cc5c4b 100644
--- a/addons/web/static/src/js/widgets/model_field_selector.js
+++ b/addons/web/static/src/js/widgets/model_field_selector.js
@@ -317,12 +317,14 @@ var ModelFieldSelector = Widget.extend({
_getModelFieldsFromCache: function (model, filters) {
var def = modelFieldsCache.cacheDefs[model];
if (!def) {
- def = modelFieldsCache.cacheDefs[model] = this.performModelRPC(model, "fields_get", [
- false,
- ["store", "searchable", "type", "string", "relation", "selection", "related"],
- ]).then((function (fields) {
- modelFieldsCache.cache[model] = sortFields(fields);
- }).bind(this));
+ def = modelFieldsCache.cacheDefs[model] = this.rpc(model, "fields_get")
+ .args([
+ false,
+ ["store", "searchable", "type", "string", "relation", "selection", "related"]])
+ .exec()
+ .then((function (fields) {
+ modelFieldsCache.cache[model] = sortFields(fields);
+ }).bind(this));
}
return def.then((function () {
return _.filter(modelFieldsCache.cache[model], function (f) {
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 b953791eec2..feaf487fcc7 100644
--- a/addons/web/static/src/js/widgets/switch_company_menu.js
+++ b/addons/web/static/src/js/widgets/switch_company_menu.js
@@ -18,9 +18,12 @@ 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.performModelRPC('res.users', 'write', [[session.uid], {'company_id': company_id}]).then(function() {
- location.reload();
- });
+ self.rpc('res.users', 'write')
+ .args([[session.uid], {'company_id': company_id}])
+ .exec()
+ .then(function() {
+ location.reload();
+ });
}, 1500, true));
self.$('.oe_topbar_name').text(session.user_companies.current_company[1]);