[REF] web, *: remove calls to performmodelrpc
The this.performModelRPc method is deprecated, so with this commit, we remove some calls.
This commit is contained in:
committed by
Aaron Bohy
parent
47ec89d7fa
commit
25fecd932a
@@ -267,69 +267,75 @@ 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],
|
||||
};
|
||||
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],
|
||||
};
|
||||
});
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
// 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..."),
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
odoo.define('web.planner.common', function (require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
var core = require('web.core');
|
||||
var Dialog = require('web.Dialog');
|
||||
var dom = require('web.dom');
|
||||
var Widget = require('web.Widget');
|
||||
var rpc = require('web.rpc');
|
||||
var session = require('web.session');
|
||||
var utils = require('web.utils');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
var QWeb = core.qweb;
|
||||
|
||||
@@ -66,10 +68,10 @@ var PlannerDialog = Dialog.extend({
|
||||
* Fetch the planner's rendered template
|
||||
*/
|
||||
willStart: function() {
|
||||
var def = this.rpc('web.planner', 'render')
|
||||
var def = rpc.query({model: 'web.planner', method: 'render'})
|
||||
.args([this.planner.view_id[0], this.planner.planner_application])
|
||||
.withContext(session.user_context)
|
||||
.exec()
|
||||
.exec({callback: ajax.rpc.bind(ajax)})
|
||||
.then((function (template) {
|
||||
this.$template = $(template);
|
||||
}).bind(this));
|
||||
@@ -351,20 +353,19 @@ var PlannerDialog = Dialog.extend({
|
||||
this._save_planner_data();
|
||||
},
|
||||
_save_planner_data: function() {
|
||||
return this.rpc('web.planner', 'write')
|
||||
return rpc.query({model: 'web.planner', method: 'write'})
|
||||
.args([this.planner.id, {'data': JSON.stringify(this.planner.data), 'progress': this.planner.progress}])
|
||||
.exec();
|
||||
.exec({callback: ajax.rpc.bind(ajax)});
|
||||
},
|
||||
show_enterprise: function () {
|
||||
var self = this;
|
||||
var buttons = [{
|
||||
text: _t("Upgrade now"),
|
||||
classes: 'btn-primary',
|
||||
close: true,
|
||||
click: function () {
|
||||
self.rpc("res.users", "search_count")
|
||||
rpc.query({model: "res.users", method: "search_count"})
|
||||
.args([[["share", "=", false]]])
|
||||
.exec()
|
||||
.exec({callback: ajax.rpc.bind(ajax)})
|
||||
.then(function (data) {
|
||||
window.location = "https://www.odoo.com/odoo-enterprise/upgrade?utm_medium=community_upgrade&num_users=" + data;
|
||||
});
|
||||
@@ -392,6 +393,9 @@ var PlannerLauncher = Widget.extend({
|
||||
events: {
|
||||
"click": "show_dialog"
|
||||
},
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
start: function () {
|
||||
this.$progress = this.$(".progress");
|
||||
this.$progressBar = this.$progress.find(".progress-bar");
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
odoo.define('website_blog.new_blog_post', function (require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
var core = require('web.core');
|
||||
var rpc = require('web.rpc');
|
||||
var base = require('web_editor.base');
|
||||
var website = require('website.website');
|
||||
var contentMenu = require('website.contentMenu');
|
||||
@@ -10,22 +12,25 @@ var _t = core._t;
|
||||
|
||||
contentMenu.TopBar.include({
|
||||
new_blog_post: function () {
|
||||
this.performModelRPC('blog.blog', 'name_search', [], { context: base.get_context() }).then(function (blog_ids) {
|
||||
if (blog_ids.length === 1) {
|
||||
document.location = '/blog/' + blog_ids[0][0] + '/post/new';
|
||||
} else if (blog_ids.length > 1) {
|
||||
website.prompt({
|
||||
id: "editor_new_blog",
|
||||
window_title: _t("New Blog Post"),
|
||||
select: "Select Blog",
|
||||
init: function (field) {
|
||||
return blog_ids;
|
||||
},
|
||||
}).then(function (blog_id) {
|
||||
document.location = '/blog/' + blog_id + '/post/new';
|
||||
});
|
||||
}
|
||||
});
|
||||
rpc.query({model: 'blog.blog', method: 'name_search'})
|
||||
.withContext(base.get_context())
|
||||
.exec({callback: ajax.rpc.bind(ajax)})
|
||||
.then(function (blog_ids) {
|
||||
if (blog_ids.length === 1) {
|
||||
document.location = '/blog/' + blog_ids[0][0] + '/post/new';
|
||||
} else if (blog_ids.length > 1) {
|
||||
website.prompt({
|
||||
id: "editor_new_blog",
|
||||
window_title: _t("New Blog Post"),
|
||||
select: "Select Blog",
|
||||
init: function (field) {
|
||||
return blog_ids;
|
||||
},
|
||||
}).then(function (blog_id) {
|
||||
document.location = '/blog/' + blog_id + '/post/new';
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ odoo.define('website_sale_wishlist.wishlist', function (require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require('web.ajax');
|
||||
var rpc = require('web.rpc');
|
||||
var Widget = require('web.Widget');
|
||||
var base = require('web_editor.base');
|
||||
var website_sale_utils = require('website_sale.utils');
|
||||
@@ -81,9 +82,9 @@ var ProductWishlist = Widget.extend({
|
||||
var wish = tr.data('wish-id');
|
||||
var product = tr.data('product-id');
|
||||
|
||||
this.rpc('product.wishlist', 'write')
|
||||
rpc.query({model: 'product.wishlist', method: 'write'})
|
||||
.args([[wish], { active: false }, base.get_context()])
|
||||
.exec()
|
||||
.exec({callback: ajax.rpc.bind(ajax)})
|
||||
.then(function(){
|
||||
$(tr).hide();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user