diff options
| author | fwi-odoo <fwi@odoo.com> | 2017-09-15 10:19:16 +0200 |
|---|---|---|
| committer | fwi-odoo <fwi@odoo.com> | 2017-09-29 16:49:20 +0200 |
| commit | da136d83bb4cd952dc0e2417d67679cfc5068f34 (patch) | |
| tree | d149d19de2188ecd5f5aff05bea09c6201e78211 /addons/web/static/src/js/core | |
| parent | a7d1740e475c44b50d0cc6ce6f43e9f142e99334 (diff) | |
[IMP] web: x2m list: conditionnaly hide a column
This commit introduces a new way to hide a column in a x2m list view.
The attribute 'tree_invisible' can be add in the field attrs in the x2m
view definition. This attribute can use the 'parent' key to make a reference
to the parent record (e.g. 'parent.id').
Diffstat (limited to 'addons/web/static/src/js/core')
| -rw-r--r-- | addons/web/static/src/js/core/domain.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/addons/web/static/src/js/core/domain.js b/addons/web/static/src/js/core/domain.js index 7b873926727..75aaf0105ed 100644 --- a/addons/web/static/src/js/core/domain.js +++ b/addons/web/static/src/js/core/domain.js @@ -51,13 +51,30 @@ var Domain = collections.Tree.extend({ } else if (_.isArray(this._data)) { // The domain is a [name, operator, value] entity // First check if we have the field value in the field values set - if (!(this._data[0] in values)) { + // and if the first part of the domain contains 'parent.field' + // get the value from the parent record. + var isParentField = false; + var fieldName = this._data[0]; + // We split the domain first part and check if it's a match + // for the syntax 'parent.field'. + var parentField = this._data[0].split('.'); + if ('parent' in values && parentField.length === 2) { + fieldName = parentField[1]; + isParentField = parentField[0] === 'parent' && + fieldName in values.parent; + } + if (!(this._data[0] in values) && !(isParentField)) { throw new Error(_.str.sprintf( "Unknown field %s in domain", this._data[0] )); } - var fieldValue = values[this._data[0]]; + var fieldValue; + if (!isParentField) { + fieldValue = values[fieldName]; + } else { + fieldValue = values.parent[fieldName]; + } switch (this._data[1]) { case "=": |
