diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js
index 09fc31101bf..7f35e08d903 100644
--- a/addons/board/static/src/js/dashboard.js
+++ b/addons/board/static/src/js/dashboard.js
@@ -2,12 +2,12 @@ odoo.define('board.dashboard', function (require) {
"use strict";
var ActionManager = require('web.ActionManager');
+var Context = require('web.Context');
var core = require('web.core');
var data = require('web.data');
var Dialog = require('web.Dialog');
var FavoriteMenu = require('web.FavoriteMenu');
var form_common = require('web.view_dialogs');
-var Model = require('web.DataModel');
var pyeval = require('web.pyeval');
var ViewManager = require('web.ViewManager');
@@ -395,7 +395,7 @@ FavoriteMenu.include({
var self = this;
var search_data = this.searchview.build_search_data(),
- context = new data.CompoundContext(this.searchview.dataset.get_context() || []),
+ context = new Context(this.searchview.dataset.get_context() || []),
domain = new data.CompoundDomain(this.searchview.dataset.get_domain() || []);
_.each(search_data.contexts, context.add, context);
_.each(search_data.domains, domain.add, domain);
diff --git a/addons/google_spreadsheet/static/src/js/search.js b/addons/google_spreadsheet/static/src/js/search.js
index bc91ad1ed83..0a08667e26a 100644
--- a/addons/google_spreadsheet/static/src/js/search.js
+++ b/addons/google_spreadsheet/static/src/js/search.js
@@ -2,6 +2,7 @@ odoo.define('google_spreadsheet.google.spreadsheet', function (require) {
"use strict";
var ActionManager = require('web.ActionManager');
+var Context = require('web.Context');
var core = require('web.core');
var data = require('web.data');
var FavoriteMenu = require('web.FavoriteMenu');
@@ -28,7 +29,7 @@ FavoriteMenu.include({
list_view = this.view_manager.views.list,
list_view_id = list_view ? list_view.view_id : false,
context = this.searchview.dataset.get_context() || [],
- compound_context = new data.CompoundContext(context),
+ compound_context = new Context(context),
compound_domain = new data.CompoundDomain(context),
groupbys = pyeval.eval('groupbys', sv_data.groupbys).join(" "),
ds = new data.DataSet(this, 'google.drive.config');
diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js
index f09f80b8a52..c72955e65a6 100644
--- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js
+++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js
@@ -2,6 +2,7 @@ odoo.define('hr_timesheet_sheet.sheet', function (require) {
"use strict";
var concurrency = require('web.concurrency');
+var Context = require('web.Context');
var core = require('web.core');
var data = require('web.data');
var form_common = require('web.view_dialogs');
@@ -59,7 +60,7 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg
var commands = this.field_manager.get_field_value("timesheet_ids");
var self = this;
this.res_o2m_drop.add(new Model(this.view.model).call("resolve_2many_commands",
- ["timesheet_ids", commands, [], new data.CompoundContext()]))
+ ["timesheet_ids", commands, [], new Context()]))
.done(function(result) {
self.set({sheets: result});
self.querying = false;
@@ -112,7 +113,7 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg
var self = this;
return this.render_drop.add(new Model("account.analytic.line").call("default_get", [
['account_id','general_account_id','journal_id','date','name','user_id','product_id','product_uom_id','amount','unit_amount','project_id'],
- new data.CompoundContext({'user_id': self.get('user_id')})
+ new Context({'user_id': self.get('user_id')})
]).then(function(result) {
default_get = result;
// calculating dates
@@ -164,7 +165,7 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg
// we need the name_get of the projects
return new Model("project.project").call("name_get", [_.pluck(projects, "project"),
- new data.CompoundContext()]).then(function(result) {
+ new Context()]).then(function(result) {
project_names = {};
_.each(result, function(el) {
project_names[el[0]] = el[1];
diff --git a/addons/mail/static/src/js/followers.js b/addons/mail/static/src/js/followers.js
index 84748f7f130..9d71039c229 100644
--- a/addons/mail/static/src/js/followers.js
+++ b/addons/mail/static/src/js/followers.js
@@ -217,7 +217,7 @@ var Followers = AbstractField.extend({
_follow: function () {
var kwargs = {
partner_ids: [this.partnerID],
- context: {}, // new data.CompoundContext(this.build_context(), {}) // fixme
+ context: {}, // new Context(this.build_context(), {}) // fixme
};
this.performModelRPC(this.model, 'message_subscribe', [[this.res_id]], kwargs)
.then(this._reload.bind(this));
@@ -237,7 +237,7 @@ var Followers = AbstractField.extend({
[self.res_id],
ids.partner_ids,
ids.channel_ids,
- {}, // new data.CompoundContext(self.build_context(), {}) // fixme
+ {}, // new Context(self.build_context(), {}) // fixme
];
self.performModelRPC(self.model, 'message_unsubscribe', args)
.then(self._reload.bind(self));
@@ -280,7 +280,7 @@ var Followers = AbstractField.extend({
} else {
var kwargs = _.extend({}, ids);
kwargs.subtype_ids = checklist;
- kwargs.context = {}; // new data.CompoundContext(this.build_context(), {}); // fixme
+ kwargs.context = {}; // new Context(this.build_context(), {}); // fixme
this.performModelRPC(this.model, 'message_subscribe', [[this.res_id]], kwargs)
.then(this._reload.bind(this));
}
diff --git a/addons/web/static/src/js/_deprecated/data.js b/addons/web/static/src/js/_deprecated/data.js
index 090325b0057..66469ff1374 100644
--- a/addons/web/static/src/js/_deprecated/data.js
+++ b/addons/web/static/src/js/_deprecated/data.js
@@ -2,6 +2,7 @@ odoo.define('web.data', function (require) {
"use strict";
var Class = require('web.Class');
+var Context = require('web.Context');
var concurrency = require('web.concurrency');
var mixins = require('web.mixins');
var Model = require('web.Model');
@@ -68,7 +69,7 @@ var Query = Class.extend({
q._filter, to_set.filter);
break;
case 'context':
- q._context = new CompoundContext(
+ q._context = new Context(
q._context, to_set.context);
break;
case 'lazy':
@@ -379,7 +380,7 @@ var DataSet = Class.extend(mixins.PropertiesMixin, {
if (options.check_access_rule === true){
method = 'search_read';
ids_arg = [['id', 'in', ids]];
- context = new CompoundContext(context, {active_test: false});
+ context = new Context(context, {active_test: false});
}
return this._model.call(method,
[ids_arg, fields || false],
@@ -729,32 +730,6 @@ var DataSetSearch = DataSet.extend({
}
});
-var CompoundContext = Class.extend({
- init: function () {
- this.__ref = "compound_context";
- this.__contexts = [];
- this.__eval_context = null;
- var self = this;
- _.each(arguments, function(x) {
- self.add(x);
- });
- },
- add: function (context) {
- this.__contexts.push(context);
- return this;
- },
- set_eval_context: function (eval_context) {
- this.__eval_context = eval_context;
- return this;
- },
- get_eval_context: function () {
- return this.__eval_context;
- },
- eval: function() {
- return pyeval.eval('context', this);
- },
-});
-
var CompoundDomain = Class.extend({
init: function () {
this.__ref = "compound_domain";
@@ -799,13 +774,13 @@ function build_eval_context (record) {
field_values.active_ids = [record.data.id];
}
// FIXME: parent?
- return new CompoundContext(field_values);
+ return new Context(field_values);
}
function build_context(record, context) {
context = context || {};
var eval_context = build_eval_context(record);
- return new CompoundContext(context).set_eval_context(eval_context);
+ return new Context(context).set_eval_context(eval_context);
}
function build_domain(record, domain) {
@@ -819,7 +794,6 @@ return {
DataSet: DataSet,
DataSetStatic: DataSetStatic,
DataSetSearch: DataSetSearch,
- CompoundContext: CompoundContext,
CompoundDomain: CompoundDomain,
noDisplayContent: "" + _t("Unnamed") + "",
build_context: build_context,
diff --git a/addons/web/static/src/js/_deprecated/data_model.js b/addons/web/static/src/js/_deprecated/data_model.js
index f722339167f..3bae06a3f4c 100644
--- a/addons/web/static/src/js/_deprecated/data_model.js
+++ b/addons/web/static/src/js/_deprecated/data_model.js
@@ -1,6 +1,7 @@
odoo.define('web.DataModel', function (require) {
"use strict";
+var Context = require('web.Context');
var data = require('web.data');
var Model = require('web.Model');
var pyeval = require('web.pyeval');
@@ -31,10 +32,10 @@ Model.include({
* combined with the provided context if any
*
* @param {Object} [context] to combine with the model's internal context
- * @returns {instance.web.CompoundContext} The union of the user's context and the model's internal context, as well as the provided context if any. In that order.
+ * @returns {web.Context} The union of the user's context and the model's internal context, as well as the provided context if any. In that order.
*/
context: function (context) {
- return new data.CompoundContext(session.user_context, this._context, context || {});
+ return new Context(session.user_context, this._context, context || {});
},
/**
* Call a method (over RPC) on the bound OpenERP model.
diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js
index 9dfe28e01dd..8db4fab8094 100644
--- a/addons/web/static/src/js/chrome/action_manager.js
+++ b/addons/web/static/src/js/chrome/action_manager.js
@@ -11,6 +11,7 @@ odoo.define('web.ActionManager', function (require) {
var Bus = require('web.Bus');
var ControlPanel = require('web.ControlPanel');
+var Context = require('web.Context');
var core = require('web.core');
var crash_manager = require('web.crash_manager');
var data = require('web.data');
@@ -620,7 +621,7 @@ var ActionManager = Widget.extend({
// Ensure context & domain are evaluated and can be manipulated/used
var user_context = this.getSession().user_context;
- var ncontext = new data.CompoundContext(user_context, options.additional_context, action.context || {});
+ var ncontext = new Context(user_context, options.additional_context, action.context || {});
action.context = pyeval.eval('context', ncontext);
if (action.context.active_id || action.context.active_ids) {
// Here we assume that when an `active_id` or `active_ids` is used
diff --git a/addons/web/static/src/js/chrome/search_inputs.js b/addons/web/static/src/js/chrome/search_inputs.js
index bf7d16b210c..934204eb0ab 100644
--- a/addons/web/static/src/js/chrome/search_inputs.js
+++ b/addons/web/static/src/js/chrome/search_inputs.js
@@ -1,6 +1,7 @@
odoo.define('web.search_inputs', function (require) {
"use strict";
+var Context = require('web.Context');
var core = require('web.core');
var data = require('web.data');
var field_utils = require('web.field_utils');
@@ -118,13 +119,13 @@ var Field = Input.extend( /** @lends instance.web.search.Field# */ {
return;
}
var contexts = facet.values.map(function (facetValue) {
- return new data.CompoundContext(context)
+ return new Context(context)
.set_eval_context({self: self.value_from(facetValue)});
});
if (contexts.length === 1) { return contexts[0]; }
- return _.extend(new data.CompoundContext(), {
+ return _.extend(new Context(), {
__contexts: contexts
});
},
@@ -588,7 +589,7 @@ var FilterGroup = Input.extend(/** @lends instance.web.search.FilterGroup# */{
if (!contexts.length) { return; }
if (contexts.length === 1) { return contexts[0]; }
- return _.extend(new data.CompoundContext(), {
+ return _.extend(new Context(), {
__contexts: contexts
});
},
diff --git a/addons/web/static/src/js/chrome/sidebar.js b/addons/web/static/src/js/chrome/sidebar.js
index 79b06f9ee4d..b57e94e422c 100644
--- a/addons/web/static/src/js/chrome/sidebar.js
+++ b/addons/web/static/src/js/chrome/sidebar.js
@@ -1,6 +1,7 @@
odoo.define('web.Sidebar', function (require) {
"use strict";
+var Context = require('web.Context');
var core = require('web.core');
var data = require('web.data');
var Dialog = require('web.Dialog');
@@ -144,15 +145,15 @@ var Sidebar = Widget.extend({
active_ids_context.active_domain = domain;
}
var c = pyeval.eval('context',
- new data.CompoundContext(
+ new Context(
sidebar_eval_context, active_ids_context));
self.rpc("/web/action/load", {
action_id: item.action.id,
- context: new data.CompoundContext(
+ context: new Context(
dataset.get_context(), active_ids_context).eval()
}).done(function(result) {
- result.context = new data.CompoundContext(
+ result.context = new Context(
result.context || {}, active_ids_context)
.set_eval_context(c);
result.flags = result.flags || {};
diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js
index 5b30d1a3c5c..0566b3042be 100644
--- a/addons/web/static/src/js/chrome/view_manager.js
+++ b/addons/web/static/src/js/chrome/view_manager.js
@@ -1,6 +1,7 @@
odoo.define('web.ViewManager', function (require) {
"use strict";
+var Context = require('web.Context');
var ControlPanelMixin = require('web.ControlPanelMixin');
var core = require('web.core');
var data = require('web.data');
@@ -538,7 +539,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
do_execute_action: function (action_data, model, record_id, on_closed) {
var self = this;
var result_handler = on_closed || function () {};
- var context = new data.CompoundContext(this.env.context, action_data.context || {});
+ var context = new Context(this.env.context, action_data.context || {});
// response handler
var handler = function (action) {
@@ -546,7 +547,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
// filter out context keys that are specific to the current action.
// Wrong default_* and search_default_* values will no give the expected result
// Wrong group_by values will simply fail and forbid rendering of the destination view
- var ncontext = new data.CompoundContext(
+ var ncontext = new Context(
_.object(_.reject(_.pairs(self.env.context), function(pair) {
return pair[0].match('^(?:(?:default_|search_default_|show_).+|.+_view_ref|group_by|group_by_no_leaf|active_id|active_ids)$') !== null;
}))
diff --git a/addons/web/static/src/js/core/context.js b/addons/web/static/src/js/core/context.js
new file mode 100644
index 00000000000..c63c9f15bd8
--- /dev/null
+++ b/addons/web/static/src/js/core/context.js
@@ -0,0 +1,35 @@
+odoo.define('web.Context', function (require) {
+"use strict";
+
+var Class = require('web.Class');
+var pyeval = require('web.pyeval');
+
+var Context = Class.extend({
+ init: function () {
+ this.__ref = "compound_context";
+ this.__contexts = [];
+ this.__eval_context = null;
+ var self = this;
+ _.each(arguments, function(x) {
+ self.add(x);
+ });
+ },
+ add: function (context) {
+ this.__contexts.push(context);
+ return this;
+ },
+ set_eval_context: function (eval_context) {
+ this.__eval_context = eval_context;
+ return this;
+ },
+ get_eval_context: function () {
+ return this.__eval_context;
+ },
+ eval: function() {
+ return pyeval.eval('context', this);
+ },
+});
+
+return Context;
+
+});
\ No newline at end of file
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 4282d78faf7..25c96a76a80 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -16,6 +16,7 @@ odoo.define('web.relational_fields', function (require) {
var AbstractField = require('web.AbstractField');
var concurrency = require('web.concurrency');
var config = require('web.config');
+var Context = require('web.Context');
var ControlPanel = require('web.ControlPanel');
var dialogs = require('web.view_dialogs');
var core = require('web.core');
@@ -376,7 +377,7 @@ var FieldMany2One = AbstractRelationalField.extend(mixins.ServicesMixin, {
new dialogs.SelectCreateDialog(this, _.extend({}, this.nodeOptions, {
res_model: this.field.relation,
domain: data.build_domain(this.record, this.domain),
- context: new data.CompoundContext(data.build_context(this.record, this.context), context || {}),
+ context: new Context(data.build_context(this.record, this.context), context || {}),
title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string,
initial_ids: ids ? _.map(ids, function (x) { return x[0]; }) : undefined,
initial_view: view,
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js
index c2855c8aaa4..2028127c202 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -79,6 +79,7 @@ odoo.define('web.BasicModel', function (require) {
var AbstractModel = require('web.AbstractModel');
var concurrency = require('web.concurrency');
+var Context = require('web.Context');
var data = require('web.data'); // TODO: remove dependency to data.js
var pyeval = require('web.pyeval');
var session = require('web.session');
@@ -1557,7 +1558,7 @@ var Model = AbstractModel.extend({
* @returns {Object} the evaluated context
*/
_getContext: function (element, options) {
- var context = new data.CompoundContext(session.user_context, element.context);
+ var context = new Context(session.user_context, element.context);
if (options && options.field) {
var attrs = element.fieldAttrs[options.field];
if (attrs && attrs.context) {
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 df944c2bd03..0c1c4bc3d59 100644
--- a/addons/web/static/src/js/views/kanban/kanban_controller.js
+++ b/addons/web/static/src/js/views/kanban/kanban_controller.js
@@ -9,7 +9,7 @@ odoo.define('web.KanbanController', function (require) {
var BasicController = require('web.BasicController');
var core = require('web.core');
-var data = require('web.data');
+var Context = require('web.Context');
var form_common = require('web.view_dialogs');
var _t = core._t;
@@ -265,7 +265,7 @@ var KanbanController = BasicController.extend({
var self = this;
var record = event.target;
if (event.data.context) {
- event.data.context = new data.CompoundContext(event.data.context)
+ event.data.context = new Context(event.data.context)
.set_eval_context({
active_id: event.target.id,
active_ids: [event.target.id],
diff --git a/addons/web/static/test/core/pyeval_tests.js b/addons/web/static/test/core/pyeval_tests.js
index c04d32d96d3..cde5193ce9d 100644
--- a/addons/web/static/test/core/pyeval_tests.js
+++ b/addons/web/static/test/core/pyeval_tests.js
@@ -1,6 +1,7 @@
odoo.define('web.pyEval_tests', function(require) {
"use strict";
+var Context = require('web.Context');
var data = require('web.data');
var pyEval = require('web.pyeval');
var time = require('web.time');
@@ -577,7 +578,7 @@ QUnit.module('core', function () {
// setup(session);
var c = "{'default_opportunity_id': active_id, 'default_duration': 1.0, 'lng': lang}";
- var cc = new data.CompoundContext(c);
+ var cc = new Context(c);
cc.set_eval_context({active_id: 42});
var result = pyEval.eval_domains_and_contexts({
domains:[], contexts: [this.user_context, cc]
diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml
index cc4dbc55193..158f23c7cde 100644
--- a/addons/web/views/webclient_templates.xml
+++ b/addons/web/views/webclient_templates.xml
@@ -150,6 +150,7 @@
+