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/services/data_manager.js | |
| 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/services/data_manager.js')
| -rw-r--r-- | addons/web/static/src/js/services/data_manager.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/addons/web/static/src/js/services/data_manager.js b/addons/web/static/src/js/services/data_manager.js index 22c7e86ba7d..48a0e2676ae 100644 --- a/addons/web/static/src/js/services/data_manager.js +++ b/addons/web/static/src/js/services/data_manager.js @@ -283,15 +283,15 @@ return core.Class.extend({ // the invisible attribute of a field is supposed to be static ("1" in // general), but not totally as it may use keys of the context // ("context.get('some_key')"). It is evaluated server-side, and the - // result is put inside the modifiers as a value of the '(tree_)invisible' + // result is put inside the modifiers as a value of the '(column_)invisible' // key, and the raw value is left in the invisible attribute (it is used // in debug mode for informational purposes). // this should change, for instance the server might set the evaluated // value in invisible, which could then be seen as static by the client, // and add another key in debug mode containing the raw value. - // for now, we do an hack to detect if the value is static and retrieve - // it from the modifiers, - if (attrs.invisible && attrs.modifiers.match('"(?:tree_)?invisible": ?true')) { + // for now, we look inside the modifiers and consider the value only if + // it is static (=== true), + if (attrs.modifiers.invisible === true || attrs.modifiers.column_invisible === true) { attrs.__no_fetch = true; } @@ -357,6 +357,15 @@ return core.Class.extend({ attrs.orderedBy = [{name: handleField.attrs.name, asc: true}]; } } + + attrs.columnInvisibleFields = {}; + _.each(view.arch.children, function (child) { + if (child.attrs && child.attrs.modifiers) { + attrs.columnInvisibleFields[child.attrs.name] = + child.attrs.modifiers.column_invisible || false; + } + }); + // detect editables list has they behave differently with respect // to the sorting (changes are not sorted directly) if (mode === 'list' && view.arch.attrs.editable) { @@ -396,6 +405,9 @@ return core.Class.extend({ if (typeof node === 'string') { return false; } + if (!_.isObject(node.attrs.modifiers)) { + node.attrs.modifiers = node.attrs.modifiers ? JSON.parse(node.attrs.modifiers) : {}; + } if (node.tag === 'field') { fieldsInfo[node.attrs.name] = self._processField(viewType, fields[node.attrs.name], node.attrs ? _.clone(node.attrs) : {}); |
