1 openerp.testing.section('eval.types', {
2 dependencies: ['web.core'],
3 setup: function (instance) {
4 instance.session.uid = 42;
7 var makeTimeCheck = function (instance) {
8 var context = instance.web.pyeval.context();
9 return function (expr, func, message) {
10 // evaluate expr between two calls to new Date(), and check that
11 // the result is between the transformed dates
13 var result = py.eval(expr, context);
15 ok(func(d0) <= result && result <= func(d1), message);
18 test('strftime', function (instance) {
19 var check = makeTimeCheck(instance);
20 check("time.strftime('%Y')", function(d) {
21 return String(d.getFullYear());
23 check("time.strftime('%Y')+'-01-30'", function(d) {
24 return String(d.getFullYear()) + '-01-30';
26 check("time.strftime('%Y-%m-%d %H:%M:%S')", function(d) {
27 return _.str.sprintf('%04d-%02d-%02d %02d:%02d:%02d',
28 d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(),
29 d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds());
32 test('context_today', function (instance) {
33 var check = makeTimeCheck(instance);
34 check("context_today().strftime('%Y-%m-%d')", function(d) {
35 return String(_.str.sprintf('%04d-%02d-%02d',
36 d.getFullYear(), d.getMonth() + 1, d.getDate()));
39 // Port from pypy/lib_pypy/test_datetime.py
40 var makeEq = function (instance, c2) {
41 var ctx = instance.web.pyeval.context();
42 var c = _.extend({ td: ctx.datetime.timedelta }, c2 || {});
43 return function (a, b, message) {
44 ok(py.eval(a + ' == ' + b, c), message);
47 test('timedelta.test_constructor', function (instance) {
48 var eq = makeEq(instance);
50 // keyword args to constructor
51 eq('td()', 'td(weeks=0, days=0, hours=0, minutes=0, seconds=0, ' +
52 'milliseconds=0, microseconds=0)');
53 eq('td(1)', 'td(days=1)');
54 eq('td(0, 1)', 'td(seconds=1)');
55 eq('td(0, 0, 1)', 'td(microseconds=1)');
56 eq('td(weeks=1)', 'td(days=7)');
57 eq('td(days=1)', 'td(hours=24)');
58 eq('td(hours=1)', 'td(minutes=60)');
59 eq('td(minutes=1)', 'td(seconds=60)');
60 eq('td(seconds=1)', 'td(milliseconds=1000)');
61 eq('td(milliseconds=1)', 'td(microseconds=1000)');
63 // Check float args to constructor
64 eq('td(weeks=1.0/7)', 'td(days=1)');
65 eq('td(days=1.0/24)', 'td(hours=1)');
66 eq('td(hours=1.0/60)', 'td(minutes=1)');
67 eq('td(minutes=1.0/60)', 'td(seconds=1)');
68 eq('td(seconds=0.001)', 'td(milliseconds=1)');
69 eq('td(milliseconds=0.001)', 'td(microseconds=1)');
71 test('timedelta.test_computations', function (instance) {
72 var c = instance.web.pyeval.context();
73 var zero = py.float.fromJSON(0);
74 var eq = makeEq(instance, {
76 a: py.PY_call(c.datetime.timedelta, [
77 py.float.fromJSON(7)]),
79 b: py.PY_call(c.datetime.timedelta, [
80 zero, py.float.fromJSON(60)]),
82 c: py.PY_call(c.datetime.timedelta, [
83 zero, zero, py.float.fromJSON(1000)]),
86 eq('a+b+c', 'td(7, 60, 1000)');
87 eq('a-b', 'td(6, 24*3600 - 60)');
90 eq('-b', 'td(-1, 24*3600 - 60)');
91 eq('-c', 'td(-1, 24*3600 - 1, 999000)');
93 // eq('abs(-a)', 'a');
94 eq('td(6, 24*3600)', 'a');
95 eq('td(0, 0, 60*1000000)', 'b');
98 // eq('a*10L', '10*a');
99 eq('b*10', 'td(0, 600)');
100 eq('10*b', 'td(0, 600)');
101 // eq('b*10L', 'td(0, 600)');
102 eq('c*10', 'td(0, 0, 10000)');
103 eq('10*c', 'td(0, 0, 10000)');
104 // eq('c*10L', 'td(0, 0, 10000)');
108 eq('b*(60*24)', '(b*60)*24');
109 eq('b*(60*24)', '(60*b)*24');
110 eq('c*1000', 'td(0, 1)');
111 eq('1000*c', 'td(0, 1)');
113 eq('b//10', 'td(0, 6)');
114 eq('c//1000', 'td(0, 0, 1)');
115 eq('a//10', 'td(0, 7*24*360)');
116 eq('a//3600000', 'td(0, 0, 7*24*1000)');
119 eq('td(999999999, 86399, 999999) - td(999999999, 86399, 999998)', 'td(0, 0, 1)');
120 eq('td(999999999, 1, 1) - td(999999999, 1, 0)',
123 test('timedelta.test_basic_attributes', function (instance) {
124 var ctx = instance.web.pyeval.context();
125 strictEqual(py.eval('datetime.timedelta(1, 7, 31).days', ctx), 1);
126 strictEqual(py.eval('datetime.timedelta(1, 7, 31).seconds', ctx), 7);
127 strictEqual(py.eval('datetime.timedelta(1, 7, 31).microseconds', ctx), 31);
129 test('timedelta.test_total_seconds', function (instance) {
130 var c = { timedelta: instance.web.pyeval.context().datetime.timedelta };
131 strictEqual(py.eval('timedelta(365).total_seconds()', c), 31536000);
133 py.eval('timedelta(seconds=123456.789012).total_seconds()', c),
136 py.eval('timedelta(seconds=-123456.789012).total_seconds()', c),
139 py.eval('timedelta(seconds=0.123456).total_seconds()', c), 0.123456);
140 strictEqual(py.eval('timedelta().total_seconds()', c), 0);
142 py.eval('timedelta(seconds=1000000).total_seconds()', c), 1e6);
144 test('timedelta.test_str', function (instance) {
145 var c = { td: instance.web.pyeval.context().datetime.timedelta };
147 strictEqual(py.eval('str(td(1))', c), "1 day, 0:00:00");
148 strictEqual(py.eval('str(td(-1))', c), "-1 day, 0:00:00");
149 strictEqual(py.eval('str(td(2))', c), "2 days, 0:00:00");
150 strictEqual(py.eval('str(td(-2))', c), "-2 days, 0:00:00");
152 strictEqual(py.eval('str(td(hours=12, minutes=58, seconds=59))', c),
154 strictEqual(py.eval('str(td(hours=2, minutes=3, seconds=4))', c),
157 py.eval('str(td(weeks=-30, hours=23, minutes=12, seconds=34))', c),
158 "-210 days, 23:12:34");
160 strictEqual(py.eval('str(td(milliseconds=1))', c), "0:00:00.001000");
161 strictEqual(py.eval('str(td(microseconds=3))', c), "0:00:00.000003");
164 py.eval('str(td(days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999))', c),
165 "999999999 days, 23:59:59.999999");
167 test('timedelta.test_massive_normalization', function (instance) {
169 instance.web.pyeval.context().datetime.timedelta,
170 {microseconds: py.float.fromJSON(-1)});
171 strictEqual(td.days, -1);
172 strictEqual(td.seconds, 24 * 3600 - 1);
173 strictEqual(td.microseconds, 999999);
175 test('timedelta.test_bool', function (instance) {
176 var c = { td: instance.web.pyeval.context().datetime.timedelta };
177 ok(py.eval('bool(td(1))', c));
178 ok(py.eval('bool(td(0, 1))', c));
179 ok(py.eval('bool(td(0, 0, 1))', c));
180 ok(py.eval('bool(td(microseconds=1))', c));
181 ok(py.eval('bool(not td(0))', c));
184 test('date.test_computations', function (instance) {
185 var d = instance.web.pyeval.context().datetime;
187 var a = d.date.fromJSON(2002, 1, 31);
188 var b = d.date.fromJSON(1956, 1, 31);
190 py.eval('(a - b).days', {a: a, b: b}),
192 strictEqual(py.eval('(a - b).seconds', {a: a, b: b}), 0);
193 strictEqual(py.eval('(a - b).microseconds', {a: a, b: b}), 0);
195 var day = py.PY_call(d.timedelta, [py.float.fromJSON(1)]);
196 var week = py.PY_call(d.timedelta, [py.float.fromJSON(7)]);
197 a = d.date.fromJSON(2002, 3, 2);
204 ok(py.eval('a + day == date(2002, 3, 3)', ctx));
205 ok(py.eval('day + a == date(2002, 3, 3)', ctx)); // 5
206 ok(py.eval('a - day == date(2002, 3, 1)', ctx));
207 ok(py.eval('-day + a == date(2002, 3, 1)', ctx));
208 ok(py.eval('a + week == date(2002, 3, 9)', ctx));
209 ok(py.eval('a - week == date(2002, 2, 23)', ctx));
210 ok(py.eval('a + 52*week == date(2003, 3, 1)', ctx)); // 10
211 ok(py.eval('a - 52*week == date(2001, 3, 3)', ctx));
212 ok(py.eval('(a + week) - a == week', ctx));
213 ok(py.eval('(a + day) - a == day', ctx));
214 ok(py.eval('(a - week) - a == -week', ctx));
215 ok(py.eval('(a - day) - a == -day', ctx)); // 15
216 ok(py.eval('a - (a + week) == -week', ctx));
217 ok(py.eval('a - (a + day) == -day', ctx));
218 ok(py.eval('a - (a - week) == week', ctx));
219 ok(py.eval('a - (a - day) == day', ctx));
222 py.eval('a + 1', ctx);
223 }, /^Error: TypeError:/); // 20
225 py.eval('a - 1', ctx);
226 }, /^Error: TypeError:/);
228 py.eval('1 + a', ctx);
229 }, /^Error: TypeError:/);
231 py.eval('1 - a', ctx);
232 }, /^Error: TypeError:/);
234 // delta - date is senseless.
236 py.eval('day - a', ctx);
237 }, /^Error: TypeError:/);
238 // mixing date and (delta or date) via * or // is senseless
240 py.eval('day * a', ctx);
241 }, /^Error: TypeError:/); // 25
243 py.eval('a * day', ctx);
244 }, /^Error: TypeError:/);
246 py.eval('day // a', ctx);
247 }, /^Error: TypeError:/);
249 py.eval('a // day', ctx);
250 }, /^Error: TypeError:/);
252 py.eval('a * a', ctx);
253 }, /^Error: TypeError:/);
255 py.eval('a // a', ctx);
256 }, /^Error: TypeError:/); // 30
257 // date + date is senseless
259 py.eval('a + a', ctx);
260 }, /^Error: TypeError:/);
262 test('relastivedelta', function (instance) {
264 py.eval("(datetime.date(2012, 2, 15) + relativedelta(days=-1)).strftime('%Y-%m-%d 23:59:59')",
265 instance.web.pyeval.context()),
266 "2012-02-14 23:59:59");
268 test('datetime.tojson', function (instance) {
269 var result = py.eval(
270 'datetime.datetime(2012, 2, 15, 1, 7, 31)',
271 instance.web.pyeval.context());
272 ok(result instanceof Date);
273 equal(result.getFullYear(), 2012);
274 equal(result.getMonth(), 1);
275 equal(result.getDate(), 15);
276 equal(result.getHours(), 1);
277 equal(result.getMinutes(), 7);
278 equal(result.getSeconds(), 31);
280 test('datetime.combine', function (instance) {
281 var result = py.eval(
282 'datetime.datetime.combine(datetime.date(2012, 2, 15),' +
283 ' datetime.time(1, 7, 13))' +
284 ' .strftime("%Y-%m-%d %H:%M:%S")',
285 instance.web.pyeval.context());
286 equal(result, "2012-02-15 01:07:13");
289 'datetime.datetime.combine(datetime.date(2012, 2, 15),' +
290 ' datetime.time())' +
291 ' .strftime("%Y-%m-%d %H:%M:%S")',
292 instance.web.pyeval.context());
293 equal(result, '2012-02-15 00:00:00');
295 test('datetime.replace', function (instance) {
296 var result = py.eval(
297 'datetime.datetime(2012, 2, 15, 1, 7, 13)' +
298 ' .replace(hour=0, minute=0, second=0)' +
299 ' .strftime("%Y-%m-%d %H:%M:%S")',
300 instance.web.pyeval.context());
301 equal(result, "2012-02-15 00:00:00");
304 openerp.testing.section('eval.edc', {
305 dependencies: ['web.data'],
307 setup: function (instance, $fix, mock) {
308 var user = { login: 'admin', id: 1, lang: 'en_US', tz: false };
309 instance.edc = function (domains, contexts) {
310 return instance.web.pyeval.eval_domains_and_contexts({
311 contexts: contexts || [],
312 domains: domains || []
315 mock('res.lang:load_lang', function () { return true; });
316 mock('res.users:write', function (args) {
317 _.extend(user, args[1]);
320 mock('/web/session/get_session_info', function () {
322 session_id: 'foobar',
333 return instance.session.session_reload();
336 test('empty, basic', {asserts: 3}, function (instance) {
337 return instance.edc().then(function (result) {
338 // default values for new db
339 deepEqual(result.context, {
344 deepEqual(result.domain, []);
345 deepEqual(result.group_by, []);
348 test('empty, context altered', {
350 setup: function (instance) {
351 var lang = new instance.web.Model('res.lang');
352 var users = new instance.web.Model('res.users');
353 return lang.call('load_lang', ['ru_RU']).then(function () {
354 return users.call('write', [instance.session.uid, {
356 tz: 'America/Santarem'
358 }).then(instance.session.session_reload.bind(instance.session));
360 }, function (instance) {
361 return instance.edc().then(function (result) {
362 // default values for new db
363 deepEqual(result.context, {
365 tz: 'America/Santarem',
368 deepEqual(result.domain, []);
369 deepEqual(result.group_by, []);
372 test('context_merge_00', {asserts: 1}, function (instance) {
376 { "lang": "en_US", "tz": false, "uid": 1 },
380 "active_model": "sale.order",
382 "default_composition_mode": "comment",
383 "default_model": "sale.order",
385 "default_template_id": 18,
386 "default_use_template": true,
387 "edi_web_url_view": "faaaake",
389 "mark_so_as_sent": null,
390 "show_address": null,
396 "__eval_context": null,
397 "__ref": "compound_context"
399 { "active_id": 9, "active_ids": [ 9 ], "active_model": "mail.compose.message" }
401 return instance.edc([], ctx).then(function (result) {
402 deepEqual(result.context, {
405 active_model: 'mail.compose.message',
407 default_composition_mode: 'comment',
408 default_model: 'sale.order',
410 default_template_id: 18,
411 default_use_template: true,
412 edi_web_url_view: "faaaake",
414 mark_so_as_sent: null,
421 test('context_merge_01', {asserts: 1}, function (instance) {
430 "default_attachment_ids": [],
432 "default_content_subtype": "html",
433 "default_model": "res.users",
434 "default_parent_id": false,
439 "__eval_context": null,
440 "__ref": "compound_context"
442 return instance.edc([], ctx).then(function (result) {
443 deepEqual(result.context, {
444 "default_attachment_ids": [],
446 "default_content_subtype": "html",
447 "default_model": "res.users",
448 "default_parent_id": false,
457 openerp.testing.section('eval.edc.nonliterals', {
458 dependencies: ['web.data'],
459 setup: function (instance) {
460 instance.session.user_context = {
466 edc: function (domains, contexts) {
467 return instance.web.pyeval.eval_domains_and_contexts({
468 contexts: contexts || [],
469 domains: domains || []
475 test('domain with time', {asserts: 1}, function (instance) {
476 return instance.edc([
477 [['type', '=', 'contract']],
478 { "__domains": [["|"], [["state", "in", ["open", "draft"]]], [["state", "=", "pending"]]],
479 "__eval_context": null,
480 "__ref": "compound_domain"
482 "['|', '&', ('date', '!=', False), ('date', '<=', time.strftime('%Y-%m-%d')), ('is_overdue_quantity', '=', True)]",
483 [['user_id', '=', 1]]
484 ]).then(function (result) {
486 var today = _.str.sprintf("%04d-%02d-%02d",
487 d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
488 deepEqual(result.domain, [
489 ["type", "=", "contract"],
490 "|", ["state", "in", ["open", "draft"]],
491 ["state", "=", "pending"],
493 "&", ["date", "!=", false],
494 ["date", "<=", today],
495 ["is_overdue_quantity", "=", true],
500 test('conditional context', {asserts: 2}, function (instance) {
503 __debug: "[('company_id', '=', context.get('company_id',False))]"
505 var e1 = instance.edc([d]).then(function (result) {
506 deepEqual(result.domain, [
507 ['company_id', '=', false]
510 var cd = new instance.web.CompoundDomain(d);
511 cd.set_eval_context({company_id: 42});
512 var e2 = instance.edc([cd]).then(function (result) {
513 deepEqual(result.domain, [
514 ['company_id', '=', 42]
518 return $.when(e1, e2);
520 test('substitution in context', {asserts: 1}, function (instance) {
521 var c = "{'default_opportunity_id': active_id, 'default_duration': 1.0, 'lng': lang}";
522 var cc = new instance.web.CompoundContext(c);
523 cc.set_eval_context({active_id: 42});
524 return instance.edc([], [cc]).then(function (result) {
525 deepEqual(result.context, {
529 default_opportunity_id: 42,
530 default_duration: 1.0,
535 test('date', {asserts: 1}, function (instance) {
536 var d = "[('state','!=','cancel'),('opening_date','>',context_today().strftime('%Y-%m-%d'))]";
537 return instance.edc([d]).then(function (result) {
539 var today = _.str.sprintf("%04d-%02d-%02d",
540 d.getFullYear(), d.getMonth() + 1, d.getDate());
541 deepEqual(result.domain, [
542 ['state', '!=', 'cancel'],
543 ['opening_date', '>', today]
547 test('delta', {asserts: 1}, function (instance) {
548 var d = "[('type','=','in'),('day','<=', time.strftime('%Y-%m-%d')),('day','>',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]";
549 return instance.edc([d]).then(function (result) {
551 var today = _.str.sprintf("%04d-%02d-%02d",
552 d.getFullYear(), d.getMonth() + 1, d.getDate());
553 d.setDate(d.getDate() - 15);
554 var ago_15_d = _.str.sprintf("%04d-%02d-%02d",
555 d.getFullYear(), d.getMonth() + 1, d.getDate());
556 deepEqual(result.domain, [
558 ['day', '<=', today],
559 ['day', '>', ago_15_d]
563 test('horror from the deep', {asserts: 1}, function (instance) {
565 {"__ref": "compound_context",
567 {"__ref": "context", "__debug": "{'k': 'foo,' + str(context.get('test_key', False))}"},
568 {"__ref": "compound_context",
570 {"lang": "en_US", "tz": false, "uid": 1},
571 {"lang": "en_US", "tz": false, "uid": 1,
572 "active_model": "sale.order", "default_type": "out",
573 "show_address": 1, "contact_display": "partner_address",
574 "active_ids": [9], "active_id": 9},
576 ], "__eval_context": null },
577 {"active_id": 8, "active_ids": [8],
578 "active_model": "stock.picking.out"},
579 {"__ref": "context", "__debug": "{'default_ref': 'stock.picking.out,'+str(context.get('active_id', False))}", "__id": "54d6ad1d6c45"}
580 ], "__eval_context": null}
582 return instance.edc([], cs).then(function (result) {
583 deepEqual(result.context, {
588 active_model: 'stock.picking.out',
593 contact_display: 'partner_address',
594 default_ref: 'stock.picking.out,8'
599 openerp.testing.section('eval.contexts', {
600 dependencies: ['web.core']
602 test('context_recursive', function (instance) {
603 var context_to_eval = [{
605 __debug: '{"foo": context.get("bar", "qux")}'
608 instance.web.pyeval.eval('contexts', context_to_eval, {bar: "ok"}),
611 instance.web.pyeval.eval('contexts', context_to_eval, {bar: false}),
614 instance.web.pyeval.eval('contexts', context_to_eval),
617 test('context_sequences', function (instance) {
618 // Context n should have base evaluation context + all of contexts
619 // 0..n-1 in its own evaluation context
621 var result = instance.web.pyeval.eval('contexts', [
625 "department_id": false,
632 { "search_default_create_uid": 1 },
635 "__eval_context": null,
636 "__ref": "compound_context"
639 "active_id": active_id,
640 "active_ids": [ active_id ],
641 "active_model": "purchase.requisition"
644 "__debug": "{'record_id' : active_id}",
645 "__id": "63e8e9bff8a6",
651 department_id: false,
657 search_default_create_uid: 1,
658 active_id: active_id,
659 active_ids: [active_id],
660 active_model: 'purchase.requisition',
664 test('non-literal_eval_contexts', function (instance) {
665 var result = instance.web.pyeval.eval('contexts', [{
666 "__ref": "compound_context",
668 {"__ref": "context", "__debug": "{'type':parent.type}",
669 "__id": "462b9dbed42f"}
672 "__ref": "compound_context",
674 "__ref": "compound_context",
676 {"__ref": "context", "__debug": "{'type': type}",
677 "__id": "16a04ed5a194"}
680 "__ref": "compound_context",
682 {"lang": "en_US", "tz": false, "uid": 1,
683 "journal_type": "sale", "section_id": false,
684 "default_type": "out_invoice",
685 "type": "out_invoice", "department_id": false},
686 {"id": false, "journal_id": 10,
687 "number": false, "type": "out_invoice",
688 "currency_id": 1, "partner_id": 4,
689 "fiscal_position": false,
690 "date_invoice": false, "period_id": false,
691 "payment_term": false, "reference_type": "none",
692 "reference": false, "account_id": 440,
693 "name": false, "invoice_line": [],
694 "tax_line": [], "amount_untaxed": 0,
695 "amount_tax": 0, "reconciled": false,
696 "amount_total": 0, "state": "draft",
697 "residual": 0, "company_id": 1,
698 "date_due": false, "user_id": 1,
699 "partner_bank_id": false, "origin": false,
700 "move_id": false, "comment": false,
701 "payment_ids": [[6, false, []]],
702 "active_id": false, "active_ids": [],
703 "active_model": "account.invoice",
705 ], "__eval_context": null}
709 "name": "[PC1] Basic PC",
715 "account_analytic_id": false,
718 "invoice_line_tax_id": [[6, false, [1]]],
721 "active_model": "account.invoice.line",
723 "id": false, "journal_id": 10, "number": false,
724 "type": "out_invoice", "currency_id": 1,
725 "partner_id": 4, "fiscal_position": false,
726 "date_invoice": false, "period_id": false,
727 "payment_term": false, "reference_type": "none",
728 "reference": false, "account_id": 440, "name": false,
729 "tax_line": [], "amount_untaxed": 0, "amount_tax": 0,
730 "reconciled": false, "amount_total": 0,
731 "state": "draft", "residual": 0, "company_id": 1,
732 "date_due": false, "user_id": 1,
733 "partner_bank_id": false, "origin": false,
734 "move_id": false, "comment": false,
735 "payment_ids": [[6, false, []]]}
737 "__eval_context": null
740 deepEqual(result, {type: 'out_invoice'});
742 test('return-input-value', function (instance) {
743 var result = instance.web.pyeval.eval('contexts', [{
744 __ref: 'compound_context',
745 __contexts: ["{'line_id': line_id , 'journal_id': journal_id }"],
747 __ref: 'compound_context',
749 __ref: 'compound_context',
751 {lang: 'en_US', tz: 'Europe/Paris', uid: 1},
752 {lang: 'en_US', tz: 'Europe/Paris', uid: 1},
755 __eval_context: null,
759 active_model: 'account.move',
769 analytic_account_id: false,
772 date_maturity: false,
789 __eval_context: null,
794 line_id: [[0, false, {
797 analytic_account_id: false,
800 date_maturity: false,
810 openerp.testing.section('eval.domains', {
811 dependencies: ['web.core', 'web.dates']
813 test('current_date', function (instance) {
814 var current_date = instance.web.date_to_str(new Date());
815 var result = instance.web.pyeval.eval('domains',
816 [[],{"__ref":"domain","__debug":"[('name','>=',current_date),('name','<=',current_date)]","__id":"5dedcfc96648"}],
817 instance.web.pyeval.context());
819 ['name', '>=', current_date],
820 ['name', '<=', current_date]
823 test('context_freevar', function (instance) {
824 var domains_to_eval = [{
826 __debug: '[("foo", "=", context.get("bar", "qux"))]'
827 }, [['bar', '>=', 42]]];
829 instance.web.pyeval.eval('domains', domains_to_eval, {bar: "ok"}),
830 [['foo', '=', 'ok'], ['bar', '>=', 42]]);
832 instance.web.pyeval.eval('domains', domains_to_eval, {bar: false}),
833 [['foo', '=', false], ['bar', '>=', 42]]);
835 instance.web.pyeval.eval('domains', domains_to_eval),
836 [['foo', '=', 'qux'], ['bar', '>=', 42]]);
839 openerp.testing.section('eval.groupbys', {
840 dependencies: ['web.core']
842 test('groupbys_00', function (instance) {
843 var result = instance.web.pyeval.eval('groupbys', [
845 {group_by: ['bar', 'qux']},
849 deepEqual(result, ['foo', 'bar', 'qux', 'grault']);
851 test('groupbys_01', function (instance) {
852 var result = instance.web.pyeval.eval('groupbys', [
854 { __ref: 'context', __debug: '{"group_by": "bar"}' },
857 deepEqual(result, ['foo', 'bar', 'grault']);
859 test('groupbys_02', function (instance) {
860 var result = instance.web.pyeval.eval('groupbys', [
863 __ref: 'compound_context',
864 __contexts: [ {group_by: 'bar'} ],
869 deepEqual(result, ['foo', 'bar', 'grault']);
871 test('groupbys_03', function (instance) {
872 var result = instance.web.pyeval.eval('groupbys', [
875 __ref: 'compound_context',
877 { __ref: 'context', __debug: '{"group_by": value}' }
879 __eval_context: { value: 'bar' }
883 deepEqual(result, ['foo', 'bar', 'grault']);
885 test('groupbys_04', function (instance) {
886 var result = instance.web.pyeval.eval('groupbys', [
889 __ref: 'compound_context',
891 { __ref: 'context', __debug: '{"group_by": value}' }
893 __eval_context: { value: 'bar' }
896 ], { value: 'bar' });
897 deepEqual(result, ['foo', 'bar', 'grault']);
899 test('groupbys_05', function (instance) {
900 var result = instance.web.pyeval.eval('groupbys', [
902 { __ref: 'context', __debug: '{"group_by": value}' },
904 ], { value: 'bar' });
905 deepEqual(result, ['foo', 'bar', 'grault']);