[FIX] web: allow strings as m2o values in domain selector
Since the new views, the field parsing for m2o returns an object with id and display_name. If the given value to parse is a string, it is supposed that this is an ID. This was breaking the domain selector widget which should allow strings as name-strings of m2o values.
This commit is contained in:
@@ -805,7 +805,7 @@ var DomainLeaf = DomainNode.extend({
|
||||
if (_.isBoolean(this.value)) {
|
||||
this.value = "";
|
||||
} else if (_.isObject(this.value) && !_.isArray(this.value)) { // Can be object if parsed to x2x representation
|
||||
this.value = this.value.id || "";
|
||||
this.value = this.value.id || value || "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,26 @@ QUnit.module('DomainSelector', {
|
||||
|
||||
domainSelector.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("building a domain with a m2o without following the relation", function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var $target = $("#qunit-fixture");
|
||||
|
||||
// Create the domain selector and its mock environment
|
||||
var domainSelector = new DomainSelector(null, "partner", [["product_id", "ilike", 1]], {
|
||||
debugMode: true,
|
||||
readonly: false,
|
||||
});
|
||||
testUtils.addMockEnvironment(domainSelector, {data: this.data});
|
||||
domainSelector.appendTo($target);
|
||||
|
||||
domainSelector.$('.o_domain_leaf_value_input').val('pad').trigger('input').trigger('change');
|
||||
assert.strictEqual(domainSelector.$('.o_domain_debug_input').val(), '[["product_id","ilike","pad"]]',
|
||||
"string should have been allowed as m2o value");
|
||||
|
||||
domainSelector.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user