summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2018-07-25 11:51:20 +0200
committerChristophe Matthieu <chm@odoo.com>2018-08-13 17:09:28 +0200
commit32b269d3d55e423604d093db4d98e6c56cab672d (patch)
treee200b484fe5ae638a2600dcad991f4850801916d /addons/web/static/src
parent061175e598939ff30c992bf606f5c9e200854072 (diff)
[IMP] web: add `default` option to DomainSelector
This option is used to set a default domain value when creating a new node (instead of [['id', '=', 1]]).
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/widgets/domain_selector.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/web/static/src/js/widgets/domain_selector.js b/addons/web/static/src/js/widgets/domain_selector.js
index dab0c97108b..948706cbd07 100644
--- a/addons/web/static/src/js/widgets/domain_selector.js
+++ b/addons/web/static/src/js/widgets/domain_selector.js
@@ -59,6 +59,8 @@ var DomainNode = Widget.extend({
* @param {Array|string} domain - the prefix representation of the domain
* @param {Object} [options] - an object with possible values:
* @param {boolean} [options.readonly=true] - true if is readonly
+ * @param {Array} [options.default] - default domain used when creating a
+ * new node
* @param {string[]} [options.operators=null]
* a list of available operators (null = all of supported ones)
* @param {boolean} [options.debugMode=false] - true if should be in debug
@@ -409,7 +411,7 @@ var DomainTree = DomainNode.extend({
* @param {OdooEvent} e
*/
_onNodeAdditionAsk: function (e) {
- var domain = [["id", "=", 1]];
+ var domain = this.options.default || [["id", "=", 1]];
if (e.data.newBranch) {
domain = [this.operator === "&" ? "|" : "&"].concat(domain).concat(domain);
}
@@ -548,7 +550,7 @@ var DomainSelector = DomainTree.extend({
* node
*/
_onAddFirstButtonClick: function () {
- this._addChild([["id", "=", 1]]);
+ this._addChild(this.options.default || [["id", "=", 1]]);
},
/**
* Called when the debug input value is changed -> constructs the tree