[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:
Alexis de Lattre
2022-08-02 22:17:09 +02:00
committed by anjeel.haria
parent a3405673c8
commit a9f6eb53e5
4 changed files with 22 additions and 24 deletions

View File

@@ -35,6 +35,7 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
this.date_delay = params.date_delay;
this.colors = params.colors;
this.fieldNames = params.fieldNames;
this.default_group_by = params.default_group_by;
this.dependency_arrow = params.dependency_arrow;
this.modelClass = params.view.model;
this.fields = params.fields;
@@ -377,7 +378,8 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
return events;
}
const groups = [];
groups.push({id: -1, content: _t("<b>UNASSIGNED</b>")});
groups.push({id: -1, content: _t("<b>UNASSIGNED</b>"), order: -1});
var seq = 1;
for (const evt of events) {
const grouped_field = _.first(group_bys);
const group_name = evt[grouped_field];
@@ -411,6 +413,8 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
}
}
if (!is_inside) {
vals.order = seq;
seq += 1;
groups.push(vals);
}
}
@@ -418,7 +422,9 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
groups.push({
id: group_name[0],
content: group_name[1],
order: seq,
});
seq += 1;
}
});
}
@@ -516,6 +522,7 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
start: date_start,
content: content,
id: evt.id,
order: evt.order,
group: group,
evt: evt,
style: `background-color: ${this.color};`,