Group by many2many field in Gantt/Tree views in Odoo 13?

139 Views Asked by At

As I have seen in this video : https://www.youtube.com/watch?v=iD2kb51Q7xg

...the feature "Group by many2many field" in Tree- and Gantt- views is available in Odoo 15: enter image description here

I have already found pieces of code corresponding to this feature in groupby_menu.js in the web module:

        _validateField(field) {
            return (field.type === "many2many" ? field.store : field.sortable) &&
                field.name !== "id" &&
                GROUPABLE_TYPES.includes(field.type);
        }

and in the module web_gantt, in its file gantt_model.js :

const isM2MGrouped = this.ganttData.fields[groupedByField].type === "many2many";
        let groupedRecords;
        if (isM2MGrouped) {
            groupedRecords = {};
            for (const [key, currentGroup] of Object.entries(currentLevelGroups)) {
                groupedRecords[key] = [];
                const value = currentGroup[0][groupedByField];
                for (const r of records || []) {
                    if (
                        !value && r[groupedByField].length === 0 ||
                        value && r[groupedByField].includes(value[0])
                    ) {
                        groupedRecords[key].push(r)
                    }
                }
            }
        } else {
            groupedRecords = groupBy(records || [], groupedByField);
        }

Has anyone advice to add this feature properly to odoo 13 or to get the corresponding module ?

1

There are 1 best solutions below

2
On

If you need it you need it. Go for it and downgrade it in order to get it working with v13 widgets. Everything it's possible and you already have an example of how it should work