diff --git a/web_timeline/README.rst b/web_timeline/README.rst index 2a306bad0..ae2046851 100644 --- a/web_timeline/README.rst +++ b/web_timeline/README.rst @@ -2,7 +2,7 @@ Web timeline ============ -.. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! @@ -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. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 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. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -257,7 +259,7 @@ promote its widespread use. Current `maintainer `__: -|maintainer-tarteo| +|maintainer-tarteo| This module is part of the `OCA/web `_ project on GitHub. diff --git a/web_timeline/readme/CONFIGURE.rst b/web_timeline/readme/CONFIGURE.rst index 49a9334b1..2b89089d6 100644 --- a/web_timeline/readme/CONFIGURE.rst +++ b/web_timeline/readme/CONFIGURE.rst @@ -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. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 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. | +--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/web_timeline/static/src/js/timeline_renderer.js b/web_timeline/static/src/js/timeline_renderer.js index aba23f760..90d4f5387 100644 --- a/web_timeline/static/src/js/timeline_renderer.js +++ b/web_timeline/static/src/js/timeline_renderer.js @@ -37,6 +37,7 @@ odoo.define("web_timeline.TimelineRenderer", function (require) { this.date_stop = params.date_stop; this.date_delay = params.date_delay; this.colors = params.colors; + this.color_field = params.color_field; this.fieldNames = params.fieldNames; this.default_group_by = params.default_group_by; this.dependency_arrow = params.dependency_arrow; @@ -512,7 +513,9 @@ odoo.define("web_timeline.TimelineRenderer", function (require) { } else { group = -1; } - + if (this.color_field) { + this.color = evt[this.color_field]; + } for (const color of this.colors) { if (py.eval(`'${evt[color.field]}' ${color.opt} '${color.value}'`)) { this.color = color.color; diff --git a/web_timeline/static/src/js/timeline_view.js b/web_timeline/static/src/js/timeline_view.js index 3971db4f7..f15434520 100644 --- a/web_timeline/static/src/js/timeline_view.js +++ b/web_timeline/static/src/js/timeline_view.js @@ -76,6 +76,11 @@ odoo.define("web_timeline.TimelineView", function (require) { ); fieldNames = _.union(fieldNames, archFieldNames); + if (attrs.color_field) { + fieldNames.push(attrs.color_field); + } + const color_field = attrs.color_field; + const colors = this.parse_colors(); for (const color of colors) { 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_delay = date_delay; this.rendererParams.colors = colors; + this.rendererParams.color_field = color_field; this.rendererParams.fieldNames = fieldNames; this.rendererParams.default_group_by = attrs.default_group_by; this.rendererParams.min_height = min_height;