summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorJinal Patel <jip@odoo.com>2019-08-09 05:09:01 +0000
committerJinal Patel <jip@odoo.com>2019-08-09 12:32:27 +0000
commitf0fdfbf44e1db97f9d9b1425be81b53138c01bd6 (patch)
tree920e6450e622108e28db2a907db376bd5ad41531 /addons/web/static/src
parenta72b23f6b5fbcf637d5de16f9f05ba00552cc186 (diff)
[FIX] web: add support for TRUE_LEAF and FALSE_LEAF in ModelFieldSelector
before this commit, domain selector widget does not support TRUE_LEAF and FALSE_LEAF i.e. [(1, '=', 1)] and [(0, '=', 1)] respectively, the reason is the chain part of the domain i.e. field name has value 1/0 and we don't have field name like 1 and 0 in domain and hence ModelFieldSelector don't accept it after this commit, domain selector can handle this special two domains which is [(1, '=', 1)] and [(0, '=', 1)], add support for chain with 1/0 in ModelFieldSelector task- 1998145 closes odoo/odoo#35603 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/widgets/domain_selector.js2
-rw-r--r--addons/web/static/src/js/widgets/model_field_selector.js7
-rw-r--r--addons/web/static/src/xml/base.xml12
3 files changed, 17 insertions, 4 deletions
diff --git a/addons/web/static/src/js/widgets/domain_selector.js b/addons/web/static/src/js/widgets/domain_selector.js
index ed71679699c..755ee32979e 100644
--- a/addons/web/static/src/js/widgets/domain_selector.js
+++ b/addons/web/static/src/js/widgets/domain_selector.js
@@ -652,7 +652,7 @@ var DomainLeaf = DomainNode.extend({
this.fieldSelector = new ModelFieldSelector(
this,
this.model,
- this.chain ? this.chain.split(".") : [],
+ this.chain !== undefined ? this.chain.toString().split(".") : [],
this.options
);
defs.push(this.fieldSelector.appendTo($("<div/>")).then((function () {
diff --git a/addons/web/static/src/js/widgets/model_field_selector.js b/addons/web/static/src/js/widgets/model_field_selector.js
index 08a7ae47c81..ed74b2da44a 100644
--- a/addons/web/static/src/js/widgets/model_field_selector.js
+++ b/addons/web/static/src/js/widgets/model_field_selector.js
@@ -301,11 +301,16 @@ var ModelFieldSelector = Widget.extend({
}).bind(this));
function processChain(chain) {
- var field = this._getLastPageField(chain.pop());
+ var fieldName = chain.pop();
+ var field = this._getLastPageField(fieldName);
if (field && field.relation && chain.length > 0) { // Fetch next chain node if any and possible
return this._pushPageData(field.relation).then(processChain.bind(this, chain));
} else if (field && chain.length === 0) { // Last node fetched
return Promise.resolve();
+ } else if (!field && fieldName === "1") { // TRUE_LEAF
+ this._validate(true);
+ } else if (!field && fieldName === "0") { // FALSE_LEAF
+ this._validate(true);
} else { // Wrong node chain
this._validate(false);
}
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index c925809fab5..062571646b6 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -767,8 +767,16 @@
<i class="fa fa-chevron-right" role="img" aria-label="Followed by" title="Followed by"/>
</t>
<span class="o_field_selector_chain_part">
- <t t-set="fieldInfo" t-value="_.findWhere(pages[fieldName_index], {'name': fieldName})"/>
- <t t-esc="fieldInfo &amp;&amp; fieldInfo.string || '?'"/>
+ <t t-if="fieldName === '1'">
+ <t t-esc="fieldName"/>
+ </t>
+ <t t-elif="fieldName === '0'">
+ <t t-esc="fieldName"/>
+ </t>
+ <t t-else="">
+ <t t-set="fieldInfo" t-value="_.findWhere(pages[fieldName_index], {'name': fieldName})"/>
+ <t t-esc="fieldInfo &amp;&amp; fieldInfo.string || '?'"/>
+ </t>
</span>
</t>
</t>