[FIX] web: domain field should never be considered unset

Indeed, false was already considered as "[]" in edit mode.
This commit is contained in:
qsm-odoo
2017-10-18 18:14:33 +02:00
parent 25e65d2bcb
commit 841f41f95b
2 changed files with 16 additions and 5 deletions
@@ -2027,6 +2027,15 @@ var FieldDomain = AbstractField.extend({
// Public
//--------------------------------------------------------------------------
/**
* A domain field is always set since the false value is considered to be
* equal to "[]" (match all records).
*
* @override
*/
isSet: function () {
return true;
},
/**
* @override isValid from AbstractField.isValid
* Parsing the char value is not enough for this field. It is considered
@@ -1957,7 +1957,7 @@ QUnit.module('basic_fields', {
QUnit.test('datetime field with date/datetime widget (with day change)', function (assert) {
assert.expect(2);
this.data.partner.records[0].p = [2];
this.data.partner.records[1].datetime = "2017-02-08 02:00:00"; // UTC
@@ -3786,7 +3786,7 @@ QUnit.module('basic_fields', {
});
QUnit.test('domain field: handle false domain as []', function (assert) {
assert.expect(2);
assert.expect(3);
this.data.partner.records[0].foo = false;
this.data.partner.fields.bar.type = "char";
@@ -3812,11 +3812,13 @@ QUnit.module('basic_fields', {
return this._super.apply(this, arguments);
},
res_id: 1,
viewOptions: {
mode: 'edit',
},
});
assert.strictEqual(form.$('.o_field_widget[name=foo]:not(.o_field_empty)').length, 1,
"there should be a domain field, not considered empty");
form.$buttons.find('.o_form_button_edit').click();
var $warning = form.$('.o_field_widget[name=foo] .text-warning');
assert.strictEqual($warning.length, 0, "should not display that the domain is invalid");