[FIX] web: filter_domain with an integer value
Before this commit, an error was returned when opening a view if the
view's searchArch contained a field with a filter_domain and the view's
context contained an integer "search_default_" for that field.
Example:
<search>
<field name="m2o" filter_domain="[('m2o', 'child_of', raw_value)]"/>
</search>
context: {
search_default_m2o: 1,
}
Part-of: odoo/odoo#97295
This commit is contained in:
@@ -153,7 +153,7 @@ export class SearchArchParser extends XMLParser {
|
||||
preField.defaultRank = -10;
|
||||
const { fieldType, fieldName } = preField;
|
||||
const { selection, context, relation } = this.fields[fieldName];
|
||||
preField.defaultAutocompleteValue = { label: value, operator, value };
|
||||
preField.defaultAutocompleteValue = { label: `${value}`, operator, value };
|
||||
if (fieldType === "selection") {
|
||||
const option = selection.find((sel) => sel[0] === value);
|
||||
if (!option) {
|
||||
|
||||
@@ -14579,4 +14579,22 @@ QUnit.module("Views", (hooks) => {
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("use a filter_domain in a list view", async function (assert) {
|
||||
await makeView({
|
||||
type: "list",
|
||||
resModel: "foo",
|
||||
serverData,
|
||||
arch: '<tree><field name="foo"/><field name="m2o"/></tree>',
|
||||
searchViewArch: `
|
||||
<search>
|
||||
<field name="m2o" filter_domain="[('m2o', 'child_of', raw_value)]"/>
|
||||
</search>`,
|
||||
context: {
|
||||
search_default_m2o: 1,
|
||||
},
|
||||
});
|
||||
|
||||
assert.containsN(target, ".o_data_row", 3);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user