recursive_tree_view: make parent field active in views where it isn't if they're recursive
This commit is contained in:
parent
da802131e8
commit
9739dbdd41
2 changed files with 8 additions and 3 deletions
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
{
|
||||
"name": "Recursive Tree View",
|
||||
"version": "17.0.0.0.1",
|
||||
"version": "17.0.0.0.2",
|
||||
"summary": "Adds the ability to mark a tree view as recursive, to expand "
|
||||
"descendants of a parent record.",
|
||||
"category": "Technical",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import {RelationalModel} from '@web/model/relational_model/relational_model';
|
||||
import {patch} from '@web/core/utils/patch';
|
||||
import {getFieldsSpec, getBasicEvalContext} from "@web/model/relational_model/utils";
|
||||
import {getFieldsSpec, getBasicEvalContext, makeActiveField} from "@web/model/relational_model/utils";
|
||||
|
||||
patch(RelationalModel.prototype, {
|
||||
// TODO: Modify the domain to include only records with parentField = False in the root search
|
||||
|
|
@ -26,6 +26,9 @@ patch(RelationalModel.prototype, {
|
|||
if (!(domain in config.domain)) {
|
||||
config.domain = config.domain.concat([domain]);
|
||||
}
|
||||
if (!(parentField in config.activeFields) || !config.activeFields[parentField]) {
|
||||
config.activeFields[parentField] = makeActiveField()
|
||||
}
|
||||
}
|
||||
return super._loadData(config);
|
||||
},
|
||||
|
|
@ -121,12 +124,13 @@ patch(RelationalModel.prototype, {
|
|||
|
||||
findRecordInHierarchy(resId) {
|
||||
const records = this.root.records;
|
||||
|
||||
function findRecord(records) {
|
||||
for (let record of records) {
|
||||
if (record.resId === resId) {
|
||||
return record;
|
||||
}
|
||||
if (record.children && record.children.length >0) {
|
||||
if (record.children && record.children.length > 0) {
|
||||
const found = findRecord(record.children);
|
||||
if (found) {
|
||||
return found;
|
||||
|
|
@ -134,6 +138,7 @@ patch(RelationalModel.prototype, {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return findRecord(records) || null;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue