summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2013-03-19 11:27:19 +0100
committerniv-openerp <nicolas.vanhoren@openerp.com>2013-03-19 11:27:19 +0100
commitc55de6996f7bbcf7393ef35de6ab0ea369621ca6 (patch)
tree8357c72ba23bd6ff77e811a83d6e9ce58826c98f /addons/web/static/src
parent19daf7569de47affc1f248cd14e505258e06c641 (diff)
[FIX] small problem with m2o, does not uses context when opening them in read-only mode
bzr revid: nicolas.vanhoren@openerp.com-20130319102719-0gdwvmix4d3x8th5
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/data.js10
-rw-r--r--addons/web/static/src/js/pyeval.js11
-rw-r--r--addons/web/static/src/js/view_form.js3
3 files changed, 17 insertions, 7 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index 5f56c4bc5f9..f1b043bacf9 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -969,7 +969,10 @@ instance.web.CompoundContext = instance.web.Class.extend({
},
get_eval_context: function () {
return this.__eval_context;
- }
+ },
+ eval: function() {
+ return instance.web.pyeval.eval('context', this, undefined, {no_user_context: true});
+ },
});
instance.web.CompoundDomain = instance.web.Class.extend({
@@ -992,7 +995,10 @@ instance.web.CompoundDomain = instance.web.Class.extend({
},
get_eval_context: function() {
return this.__eval_context;
- }
+ },
+ eval: function() {
+ return instance.web.pyeval.eval('domain', this);
+ },
});
instance.web.DropMisordered = instance.web.Class.extend({
diff --git a/addons/web/static/src/js/pyeval.js b/addons/web/static/src/js/pyeval.js
index c1e1264aaf5..c8207066ca9 100644
--- a/addons/web/static/src/js/pyeval.js
+++ b/addons/web/static/src/js/pyeval.js
@@ -603,7 +603,7 @@ openerp.web.pyeval = function (instance) {
});
var eval_contexts = function (contexts, evaluation_context) {
- evaluation_context = evaluation_context || {};
+ evaluation_context = _.extend(instance.web.pyeval.context(), evaluation_context || {});
return _(contexts).reduce(function (result_context, ctx) {
// __eval_context evaluations can lead to some of `contexts`'s
// values being null, skip them as well as empty contexts
@@ -628,9 +628,10 @@ openerp.web.pyeval = function (instance) {
// siblings
_.extend(evaluation_context, evaluated);
return _.extend(result_context, evaluated);
- }, _.extend({}, instance.session.user_context));
+ }, {});
};
var eval_domains = function (domains, evaluation_context) {
+ evaluation_context = _.extend(instance.web.pyeval.context(), evaluation_context || {});
var result_domain = [];
_(domains).each(function (domain) {
if (_.isString(domain)) {
@@ -657,6 +658,7 @@ openerp.web.pyeval = function (instance) {
return result_domain;
};
var eval_groupbys = function (contexts, evaluation_context) {
+ evaluation_context = _.extend(instance.web.pyeval.context(), evaluation_context || {});
var result_group = [];
_(contexts).each(function (ctx) {
if (_.isString(ctx)) {
@@ -707,14 +709,15 @@ openerp.web.pyeval = function (instance) {
* @param {Array} object domains or contexts to evaluate
* @param {Object} [context] evaluation context
*/
- instance.web.pyeval.eval = function (type, object, context) {
+ instance.web.pyeval.eval = function (type, object, context, options) {
+ options = options || {};
context = _.extend(instance.web.pyeval.context(), context || {});
context['context'] = py.dict.fromJSON(context);
//noinspection FallthroughInSwitchStatementJS
switch(type) {
case 'context': object = [object];
- case 'contexts': return eval_contexts(object, context);
+ case 'contexts': return eval_contexts((options.no_user_context ? [] : [instance.session.user_context]).concat(object), context);
case 'domain': object = [object];
case 'domains': return eval_domains(object, context);
case 'groupbys': return eval_groupbys(object, context);
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 42c897f0845..dff24bd4b5e 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -3277,7 +3277,8 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
res_model: self.field.relation,
res_id: self.get("value"),
views: [[false, 'form']],
- target: 'current'
+ target: 'current',
+ context: self.build_context().eval(),
});
return false;
});