[IMP] web: allow to use python expr in tree's expand
Before it was only possible to set 0 or 1 as value for expand. This constrained the creation of adaptable views with regard to to context
This commit is contained in:
@@ -14,6 +14,7 @@ var core = require('web.core');
|
||||
var ListModel = require('web.ListModel');
|
||||
var ListRenderer = require('web.ListRenderer');
|
||||
var ListController = require('web.ListController');
|
||||
var pyUtils = require('web.py_utils');
|
||||
|
||||
var _lt = core._lt;
|
||||
|
||||
@@ -41,7 +42,8 @@ var ListView = BasicView.extend({
|
||||
var selectedRecords = []; // there is no selected records by default
|
||||
|
||||
var mode = this.arch.attrs.editable && !params.readonly ? "edit" : "readonly";
|
||||
var expandGroups = !!JSON.parse(this.arch.attrs.expand || "0");
|
||||
var pyevalContext = py.dict.fromJSON(_.pick(params.context, function(value, key, object) {return !_.isUndefined(value)}) || {});
|
||||
var expandGroups = !!JSON.parse(pyUtils.py_eval(this.arch.attrs.expand || "0", {'context': pyevalContext}));
|
||||
|
||||
this.groupbys = {};
|
||||
this.arch.children.forEach(function (child) {
|
||||
|
||||
@@ -61,14 +61,7 @@
|
||||
</rng:choice>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<rng:optional>
|
||||
<rng:attribute name="expand">
|
||||
<rng:choice>
|
||||
<rng:value>1</rng:value>
|
||||
<rng:value>0</rng:value>
|
||||
</rng:choice>
|
||||
</rng:attribute>
|
||||
</rng:optional>
|
||||
<rng:optional><rng:attribute name="expand"/></rng:optional>
|
||||
<rng:zeroOrMore>
|
||||
<rng:choice>
|
||||
<rng:ref name="control"/>
|
||||
|
||||
Reference in New Issue
Block a user