[FIX] web: add session user_context in the evalcontext
When evaluating a domain, we need to add the user context, so domains can use a key such as uid.
This commit is contained in:
committed by
Aaron Bohy
parent
0cb5005946
commit
f0ee1e2be5
@@ -1915,6 +1915,10 @@ var BasicModel = AbstractModel.extend({
|
||||
* Returns the evaluation context that should be used when evaluating the
|
||||
* context/domain associated to a given element from the localData.
|
||||
*
|
||||
* It is actually quite subtle. We need to add some magic keys: active_id
|
||||
* and active_ids. Also, the session user context is added in the mix to be
|
||||
* sure. This allows some domains to use the uid key for example
|
||||
*
|
||||
* @param {Object} element - an element from the localData
|
||||
* @returns {Object}
|
||||
*/
|
||||
@@ -1932,7 +1936,7 @@ var BasicModel = AbstractModel.extend({
|
||||
}
|
||||
_.extend(evalContext, {parent: parent.data});
|
||||
}
|
||||
return evalContext;
|
||||
return _.extend({}, session.user_context, evalContext);
|
||||
},
|
||||
/**
|
||||
* Returns the list of field names of the given element according to its
|
||||
|
||||
@@ -31,6 +31,7 @@ QUnit.module('relational_fields', {
|
||||
},
|
||||
date: {string: "Some Date", type: "date"},
|
||||
datetime: {string: "Datetime Field", type: 'datetime'},
|
||||
user_id: {string: "User", type: 'many2one', relation: 'user'},
|
||||
},
|
||||
records: [{
|
||||
id: 1,
|
||||
@@ -43,6 +44,7 @@ QUnit.module('relational_fields', {
|
||||
turtles: [2],
|
||||
timmy: [],
|
||||
trululu: 4,
|
||||
user_id: 17,
|
||||
}, {
|
||||
id: 2,
|
||||
display_name: "second record",
|
||||
@@ -56,6 +58,7 @@ QUnit.module('relational_fields', {
|
||||
product_id: 37,
|
||||
date: "2017-01-25",
|
||||
datetime: "2016-12-12 10:55:05",
|
||||
user_id: 17,
|
||||
}, {
|
||||
id: 4,
|
||||
display_name: "aaa",
|
||||
@@ -119,7 +122,19 @@ QUnit.module('relational_fields', {
|
||||
turtle_qux: 9.8,
|
||||
partner_ids: [],
|
||||
}],
|
||||
}
|
||||
},
|
||||
user: {
|
||||
fields: {
|
||||
name: {string: "Name", type: "char"}
|
||||
},
|
||||
records: [{
|
||||
id: 17,
|
||||
name: "Aline",
|
||||
}, {
|
||||
id: 19,
|
||||
name: "Christine",
|
||||
}]
|
||||
},
|
||||
};
|
||||
}
|
||||
}, function () {
|
||||
@@ -3102,6 +3117,30 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('static statusbar widget on many2one field with domain', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:'<form string="Partners">' +
|
||||
'<header><field name="trululu" domain="[(\'user_id\',\'=\',uid)]" widget="statusbar"/></header>' +
|
||||
'</form>',
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'search_read') {
|
||||
assert.deepEqual(args.args[0], ['|', ['id', '=', 4], ['user_id', '=', 17]],
|
||||
"search_read should sent the correct domain");
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
res_id: 1,
|
||||
session: {user_context: {uid: 17}},
|
||||
});
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('clickable statusbar widget on many2one field', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user