mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[FIX] web_timeline: order group_by field
Fix bug #2266: before this fix, the lines of the timeline view were always sorted by alphabetical order, ignoring the native order of the model on which the group_by field points to. Fix duplicate entries in the 'fields' argument when the 'colors' parameters uses the same field in multiple conditions.
This commit is contained in:
committed by
CarlosRoca13
parent
40b956b513
commit
607da7c379
@@ -73,7 +73,9 @@ odoo.define("web_timeline.TimelineView", function (require) {
|
||||
|
||||
const colors = this.parse_colors();
|
||||
for (const color of colors) {
|
||||
fieldNames.push(color.field);
|
||||
if (!fieldNames.includes(color.field)) {
|
||||
fieldNames.push(color.field);
|
||||
}
|
||||
}
|
||||
|
||||
if (dependency_arrow) {
|
||||
@@ -107,11 +109,13 @@ odoo.define("web_timeline.TimelineView", function (require) {
|
||||
this.rendererParams.date_delay = date_delay;
|
||||
this.rendererParams.colors = colors;
|
||||
this.rendererParams.fieldNames = fieldNames;
|
||||
this.rendererParams.default_group_by = attrs.default_group_by;
|
||||
this.rendererParams.min_height = min_height;
|
||||
this.rendererParams.dependency_arrow = dependency_arrow;
|
||||
this.rendererParams.fields = fields;
|
||||
this.loadParams.modelName = this.modelName;
|
||||
this.loadParams.fieldNames = fieldNames;
|
||||
this.loadParams.default_group_by = attrs.default_group_by;
|
||||
this.controllerParams.open_popup_action = open_popup_action;
|
||||
this.controllerParams.date_start = date_start;
|
||||
this.controllerParams.date_stop = date_stop;
|
||||
@@ -122,7 +126,7 @@ odoo.define("web_timeline.TimelineView", function (require) {
|
||||
|
||||
_preapre_vis_timeline_options: function (attrs) {
|
||||
return {
|
||||
groupOrder: this.group_order,
|
||||
groupOrder: "order",
|
||||
orientation: "both",
|
||||
selectable: true,
|
||||
multiselect: true,
|
||||
@@ -135,24 +139,6 @@ odoo.define("web_timeline.TimelineView", function (require) {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Order function for groups.
|
||||
* @param {Object} grp1
|
||||
* @param {Object} grp2
|
||||
* @returns {Integer}
|
||||
*/
|
||||
group_order: function (grp1, grp2) {
|
||||
// Display non grouped elements first
|
||||
if (grp1.id === -1) {
|
||||
return -1;
|
||||
}
|
||||
if (grp2.id === -1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return grp1.content.localeCompare(grp2.content);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the colors attribute.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user