pull/2887/merge
IJOL 2025-04-24 12:03:24 +02:00 committed by GitHub
commit 502b05564e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View File

@ -69,6 +69,8 @@ the possible attributes for the tag:
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| colors | No | Allows to set certain specific colors if the expressed condition (JS syntax) is met. | | colors | No | Allows to set certain specific colors if the expressed condition (JS syntax) is met. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| color_field | No | Allows to set a field from the model to specify the color of the bar, colors will take precedence if used |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| dependency_arrow | No | Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field. | | dependency_arrow | No | Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

View File

@ -26,6 +26,8 @@ the possible attributes for the tag:
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| colors | No | Allows to set certain specific colors if the expressed condition (JS syntax) is met. | | colors | No | Allows to set certain specific colors if the expressed condition (JS syntax) is met. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| color_field | No | Gets the color for the bar from field named here, if specified colors are set after this color |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| dependency_arrow | No | Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field. | | dependency_arrow | No | Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

View File

@ -37,6 +37,7 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
this.date_stop = params.date_stop; this.date_stop = params.date_stop;
this.date_delay = params.date_delay; this.date_delay = params.date_delay;
this.colors = params.colors; this.colors = params.colors;
this.color_field = params.color_field;
this.fieldNames = params.fieldNames; this.fieldNames = params.fieldNames;
this.default_group_by = params.default_group_by; this.default_group_by = params.default_group_by;
this.dependency_arrow = params.dependency_arrow; this.dependency_arrow = params.dependency_arrow;
@ -512,7 +513,9 @@ odoo.define("web_timeline.TimelineRenderer", function (require) {
} else { } else {
group = -1; group = -1;
} }
if (this.color_field) {
this.color = evt[this.color_field];
}
for (const color of this.colors) { for (const color of this.colors) {
if (py.eval(`'${evt[color.field]}' ${color.opt} '${color.value}'`)) { if (py.eval(`'${evt[color.field]}' ${color.opt} '${color.value}'`)) {
this.color = color.color; this.color = color.color;

View File

@ -76,6 +76,11 @@ odoo.define("web_timeline.TimelineView", function (require) {
); );
fieldNames = _.union(fieldNames, archFieldNames); fieldNames = _.union(fieldNames, archFieldNames);
if (attrs.color_field) {
fieldNames.push(attrs.color_field);
}
const color_field = attrs.color_field;
const colors = this.parse_colors(); const colors = this.parse_colors();
for (const color of colors) { for (const color of colors) {
if (!fieldNames.includes(color.field)) { if (!fieldNames.includes(color.field)) {
@ -111,6 +116,7 @@ odoo.define("web_timeline.TimelineView", function (require) {
this.rendererParams.date_stop = date_stop; this.rendererParams.date_stop = date_stop;
this.rendererParams.date_delay = date_delay; this.rendererParams.date_delay = date_delay;
this.rendererParams.colors = colors; this.rendererParams.colors = colors;
this.rendererParams.color_field = color_field;
this.rendererParams.fieldNames = fieldNames; this.rendererParams.fieldNames = fieldNames;
this.rendererParams.default_group_by = attrs.default_group_by; this.rendererParams.default_group_by = attrs.default_group_by;
this.rendererParams.min_height = min_height; this.rendererParams.min_height = min_height;