[MERGE] forward port branch saas-11.3 up to 4850fb0838
This commit is contained in:
@@ -4418,6 +4418,33 @@ QUnit.module('basic_fields', {
|
||||
|
||||
QUnit.module('FieldDomain');
|
||||
|
||||
QUnit.test('The domain editor should not crash the view when given a dynamic filter', function (assert) {
|
||||
//dynamic filters (containing variables, such as uid, parent or today)
|
||||
//are not handled by the domain editor, but it shouldn't crash the view
|
||||
assert.expect(1);
|
||||
|
||||
this.data.partner.records[0].foo = '[["int_field", "=", uid]]';
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:
|
||||
'<form>' +
|
||||
'<field name="foo" widget="domain" options="{\'model\': \'partner\'}"/>' +
|
||||
'<field name="int_field" invisible="1"/>' +
|
||||
'</form>',
|
||||
res_id: 1,
|
||||
session: {
|
||||
user_context: {uid: 14},
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(form.$('.o_read_mode').text(), "This domain is not supported.",
|
||||
"The widget should not crash the view, but gracefully admit its failure.");
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('basic domain field usage is ok', function (assert) {
|
||||
assert.expect(6);
|
||||
|
||||
@@ -4567,6 +4594,43 @@ QUnit.module('basic_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('domain field can be reset with a new domain (from onchange)', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
this.data.partner.records[0].foo = '[]';
|
||||
this.data.partner.onchanges = {
|
||||
display_name: function (obj) {
|
||||
obj.foo = '[["id", "=", 1]]';
|
||||
},
|
||||
};
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:
|
||||
'<form>' +
|
||||
'<field name="display_name"/>' +
|
||||
'<field name="foo" widget="domain" options="{\'model\': \'partner\'}"/>' +
|
||||
'</form>',
|
||||
res_id: 1,
|
||||
viewOptions: {
|
||||
mode: 'edit',
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(form.$('.o_domain_show_selection_button').text().trim(), '5 record(s)',
|
||||
"the domain being empty, there should be 5 records");
|
||||
|
||||
// update display_name to trigger the onchange and reset foo
|
||||
form.$('.o_field_widget[name=display_name]').val('new value').trigger('input');
|
||||
|
||||
assert.equal(form.$('.o_domain_show_selection_button').text().trim(), '1 record(s)',
|
||||
"the domain has changed, there should be only 1 record");
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('domain field: handle false domain as []', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user