diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js
index a79df217a5a..abbcc780ee2 100644
--- a/addons/web/static/src/js/core.js
+++ b/addons/web/static/src/js/core.js
@@ -13,7 +13,7 @@ openerp.web.core = function(openerp) {
// a function to override the "extend()" method of JR's inheritance, allowing
// the usage of "include()"
-oe_override_class = function(claz){
+var oe_override_class = function(claz){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ?
/\b_super\b/ : /.*/;
@@ -625,16 +625,20 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
var result_context = _.extend({}, this.user_context),
self = this;
_(contexts).each(function (ctx) {
+ // __eval_context evaluations can lead to some of `contexts`'s
+ // values being null, skip them as well as empty contexts
+ if (_.isEmpty(ctx)) { return; }
switch(ctx.__ref) {
case 'context':
_.extend(result_context, py.eval(
ctx.__debug, evaluation_context));
break;
case 'compound_context':
+ var eval_context = self.test_eval_contexts([ctx.__eval_context]);
_.extend(
result_context, self.test_eval_contexts(
ctx.__contexts, _.extend(
- {}, evaluation_context, ctx.__eval_context)));
+ {}, evaluation_context, eval_context)));
break;
default:
_.extend(result_context, ctx);
@@ -642,19 +646,20 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
});
return result_context;
},
- test_eval_domains: function (domains, eval_context) {
+ test_eval_domains: function (domains, evaluation_context) {
var result_domain = [], self = this;
_(domains).each(function (dom) {
switch(dom.__ref) {
case 'domain':
result_domain.push.apply(
- result_domain, py.eval(dom.__debug, eval_context));
+ result_domain, py.eval(dom.__debug, evaluation_context));
break;
case 'compound_domain':
+ var eval_context = self.test_eval_contexts([dom.__eval_context]);
result_domain.push.apply(
result_domain, self.test_eval_domains(
dom.__domains, _.extend(
- {}, eval_context, dom.__eval_context)));
+ {}, evaluation_context, eval_context)));
break;
default:
result_domain.push.apply(
diff --git a/addons/web/static/test/evals.js b/addons/web/static/test/evals.js
new file mode 100644
index 00000000000..688a07dd455
--- /dev/null
+++ b/addons/web/static/test/evals.js
@@ -0,0 +1,88 @@
+$(document).ready(function () {
+ var openerp;
+
+ module("eval.contexts", {
+ setup: function () {
+ openerp = window.openerp.init();
+ window.openerp.web.core(openerp);
+ }
+ });
+ test('non-literal_eval_contexts', function () {
+ var result = openerp.connection.test_eval_contexts([{
+ "__ref": "compound_context",
+ "__contexts": [
+ {"__ref": "context", "__debug": "{'type':parent.type}",
+ "__id": "462b9dbed42f"}
+ ],
+ "__eval_context": {
+ "__ref": "compound_context",
+ "__contexts": [{
+ "__ref": "compound_context",
+ "__contexts": [
+ {"__ref": "context", "__debug": "{'type': type}",
+ "__id": "16a04ed5a194"}
+ ],
+ "__eval_context": {
+ "__ref": "compound_context",
+ "__contexts": [
+ {"lang": "en_US", "tz": false, "uid": 1,
+ "journal_type": "sale", "section_id": false,
+ "default_type": "out_invoice",
+ "type": "out_invoice", "department_id": false},
+ {"id": false, "journal_id": 10,
+ "number": false, "type": "out_invoice",
+ "currency_id": 1, "partner_id": 4,
+ "fiscal_position": false,
+ "date_invoice": false, "period_id": false,
+ "payment_term": false, "reference_type": "none",
+ "reference": false, "account_id": 440,
+ "name": false, "invoice_line": [],
+ "tax_line": [], "amount_untaxed": 0,
+ "amount_tax": 0, "reconciled": false,
+ "amount_total": 0, "state": "draft",
+ "residual": 0, "company_id": 1,
+ "date_due": false, "user_id": 1,
+ "partner_bank_id": false, "origin": false,
+ "move_id": false, "comment": false,
+ "payment_ids": [[6, false, []]],
+ "active_id": false, "active_ids": [],
+ "active_model": "account.invoice",
+ "parent": {}}
+ ], "__eval_context": null}
+ }, {
+ "id": false,
+ "product_id": 4,
+ "name": "[PC1] Basic PC",
+ "quantity": 1,
+ "uos_id": 1,
+ "price_unit": 100,
+ "account_id": 853,
+ "discount": 0,
+ "account_analytic_id": false,
+ "company_id": false,
+ "note": false,
+ "invoice_line_tax_id": [[6, false, [1]]],
+ "active_id": false,
+ "active_ids": [],
+ "active_model": "account.invoice.line",
+ "parent": {
+ "id": false, "journal_id": 10, "number": false,
+ "type": "out_invoice", "currency_id": 1,
+ "partner_id": 4, "fiscal_position": false,
+ "date_invoice": false, "period_id": false,
+ "payment_term": false, "reference_type": "none",
+ "reference": false, "account_id": 440, "name": false,
+ "tax_line": [], "amount_untaxed": 0, "amount_tax": 0,
+ "reconciled": false, "amount_total": 0,
+ "state": "draft", "residual": 0, "company_id": 1,
+ "date_due": false, "user_id": 1,
+ "partner_bank_id": false, "origin": false,
+ "move_id": false, "comment": false,
+ "payment_ids": [[6, false, []]]}
+ }],
+ "__eval_context": null
+ }
+ }]);
+ deepEqual(result, {type: 'out_invoice'});
+ });
+});
diff --git a/addons/web/static/test/test.html b/addons/web/static/test/test.html
index 10c2a2c0ed2..1e34c6ec933 100644
--- a/addons/web/static/test/test.html
+++ b/addons/web/static/test/test.html
@@ -24,7 +24,9 @@
-
+
+
+
@@ -51,4 +53,5 @@
+