From 695bd75a1383e88099a79de89db9ee1042c83d5e Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 31 Jan 2018 15:45:48 +0100 Subject: [PATCH] [FIX] web: invalid domain in DomainSelector Backport of this commit: c13c9e0b5c6ff8a8ae030ff2467d4675fb6197b8 Steps to reproduce the bug: - install application MRP Maintenance - open maintenance request form view, and from top right corner click Studio icon - click on Equipment field while you are still in studio interface - It will show left side studio panel, click Domain box and it will throw an error opw:813594 --- .../static/src/js/widgets/domain_selector.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/widgets/domain_selector.js b/addons/web/static/src/js/widgets/domain_selector.js index eccbd9d7491..5fd517ebc6f 100644 --- a/addons/web/static/src/js/widgets/domain_selector.js +++ b/addons/web/static/src/js/widgets/domain_selector.js @@ -110,7 +110,16 @@ var DomainTree = DomainNode.extend({ /// @see DomainTree._addFlattenedChildren init: function (parent, model, domain, options) { this._super.apply(this, arguments); - this._initialize(domainUtils.stringToDomain(domain)); + try { + domain = domainUtils.stringToDomain(domain); + } catch (err) { + // TODO: domain could contain `parent` for example, which is + // currently not handled by the DomainSelector + this.invalidDomain = true; + this.children = []; + return; + } + this._initialize(domain); }, /// @see DomainTree.init _initialize: function (domain) { @@ -279,6 +288,18 @@ var DomainSelector = DomainTree.extend({ } }, }), + + start: function () { + var self = this; + return this._super.apply(this, arguments).then(function () { + if (self.invalidDomain) { + var msg = _t("This domain is not supported."); + self.$el.html(msg); + } + }); + }, + + _initialize: function (domain) { // Check if the domain starts with implicit "&" operators and make them // explicit. As the DomainSelector is a specialization of a DomainTree,