diff --git a/addons/web/static/src/core/domain_selector/domain_selector.js b/addons/web/static/src/core/domain_selector/domain_selector.js index f45d43f8f3a..a7e496f5ae6 100644 --- a/addons/web/static/src/core/domain_selector/domain_selector.js +++ b/addons/web/static/src/core/domain_selector/domain_selector.js @@ -192,7 +192,7 @@ export class DomainSelector extends Component { const pathInfo = { path, fieldDef }; node.pathInfo = pathInfo; node.operatorInfo = getOperatorsInfo(pathInfo.fieldDef)[0]; - node.value = getDefaultFieldValue(pathInfo.fieldDef); + node.value = getDefaultFieldValue(pathInfo.fieldDef, node.operatorInfo.key); this.notifyChanges(); } @@ -213,12 +213,18 @@ export class DomainSelector extends Component { } // binary operator with a non array value case 1: { - node.value = getDefaultFieldValue(node.pathInfo.fieldDef); + node.value = getDefaultFieldValue( + node.pathInfo.fieldDef, + node.operatorInfo.key + ); break; } // binary operator with a fixed sized array value default: { - const defaultValue = getDefaultFieldValue(node.pathInfo.fieldDef); + const defaultValue = getDefaultFieldValue( + node.pathInfo.fieldDef, + node.operatorInfo.key + ); node.value = Array(node.operatorInfo.valueCount).fill(defaultValue); break; } @@ -237,7 +243,10 @@ export class DomainSelector extends Component { } removeExprValue(node) { - this.updateLeafValue(node, getDefaultFieldValue(node.pathInfo.fieldDef)); + this.updateLeafValue( + node, + getDefaultFieldValue(node.pathInfo.fieldDef, node.operatorInfo.key) + ); } onDebugValueChange(value) { diff --git a/addons/web/static/src/core/domain_selector/domain_selector_fields.js b/addons/web/static/src/core/domain_selector/domain_selector_fields.js index 723d3e8deb1..9447f36189d 100644 --- a/addons/web/static/src/core/domain_selector/domain_selector_fields.js +++ b/addons/web/static/src/core/domain_selector/domain_selector_fields.js @@ -388,12 +388,12 @@ export function getOperatorsInfo(fieldDef) { return selectOperators(descr.operators); } -export function getDefaultFieldValue(fieldDef) { +export function getDefaultFieldValue(fieldDef, operatorKey) { const descr = getFieldInfo(fieldDef); - return descr.defaultValue(fieldDef); + return descr.defaultValue(fieldDef, operatorKey); } export function getDefaultOperator(fieldDef) { const [firstOperator] = getOperatorsInfo(fieldDef); - return firstOperator.symbol; + return firstOperator; } diff --git a/addons/web/static/src/core/domain_selector/utils.js b/addons/web/static/src/core/domain_selector/utils.js index cf3cfa17847..8c726a22920 100644 --- a/addons/web/static/src/core/domain_selector/utils.js +++ b/addons/web/static/src/core/domain_selector/utils.js @@ -49,8 +49,8 @@ function getDefaultDomain(fieldDefs) { fieldDef = fieldDefs[name]; if (fieldDef) { const operator = getDefaultOperator(fieldDef); - const defaultValue = getDefaultFieldValue(fieldDef); - return new Domain([[fieldDef.name, operator, defaultValue]]).toString(); + const defaultValue = getDefaultFieldValue(fieldDef, operator.key); + return new Domain([[fieldDef.name, operator.symbol, defaultValue]]).toString(); } } return new Domain([["id", "=", 1]]).toString();