2012-10-26 09:21:44 +00:00
|
|
|
openerp.testing.section('compute_domain', {
|
|
|
|
dependencies: ['web.form']
|
|
|
|
}, function (test) {
|
|
|
|
test("basic", function (instance) {
|
2011-04-11 17:36:43 +00:00
|
|
|
var fields = {
|
2011-04-11 17:31:46 +00:00
|
|
|
'a': {value: 3},
|
|
|
|
'group_method': {value: 'line'},
|
|
|
|
'select1': {value: 'day'},
|
|
|
|
'rrule_type': {value: 'monthly'}
|
|
|
|
};
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(
|
2011-04-11 17:36:43 +00:00
|
|
|
[['a', '=', 3]], fields));
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(
|
2011-04-11 17:36:43 +00:00
|
|
|
[['group_method','!=','count']], fields));
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(
|
2011-04-11 17:36:43 +00:00
|
|
|
[['select1','=','day'], ['rrule_type','=','monthly']], fields));
|
2011-04-11 17:31:46 +00:00
|
|
|
});
|
2012-10-26 09:21:44 +00:00
|
|
|
test("or", function (instance) {
|
2011-09-05 11:03:09 +00:00
|
|
|
var web = {
|
2011-04-11 17:31:46 +00:00
|
|
|
'section_id': {value: null},
|
|
|
|
'user_id': {value: null},
|
|
|
|
'member_ids': {value: null}
|
|
|
|
};
|
|
|
|
|
|
|
|
var domain = ['|', ['section_id', '=', 42],
|
|
|
|
'|', ['user_id','=',3],
|
|
|
|
['member_ids', 'in', [3]]];
|
|
|
|
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(domain, _.extend(
|
2011-09-05 11:03:09 +00:00
|
|
|
{}, web, {'section_id': {value: 42}})));
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(domain, _.extend(
|
2011-09-05 11:03:09 +00:00
|
|
|
{}, web, {'user_id': {value: 3}})));
|
2011-04-11 17:31:46 +00:00
|
|
|
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(domain, _.extend(
|
2011-09-05 11:03:09 +00:00
|
|
|
{}, web, {'member_ids': {value: 3}})));
|
2011-04-11 17:31:46 +00:00
|
|
|
});
|
2012-10-26 09:21:44 +00:00
|
|
|
test("not", function (instance) {
|
2011-04-11 17:50:25 +00:00
|
|
|
var fields = {
|
|
|
|
'a': {value: 5},
|
|
|
|
'group_method': {value: 'line'}
|
|
|
|
};
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(
|
2011-04-11 17:50:25 +00:00
|
|
|
['!', ['a', '=', 3]], fields));
|
2012-10-26 09:21:44 +00:00
|
|
|
ok(instance.web.form.compute_domain(
|
2011-04-11 17:50:25 +00:00
|
|
|
['!', ['group_method','=','count']], fields));
|
|
|
|
});
|
2011-04-11 17:31:46 +00:00
|
|
|
});
|