Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions web_timeline/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Web timeline
============

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand Down Expand Up @@ -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. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Expand Down Expand Up @@ -257,7 +259,7 @@ promote its widespread use.

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-tarteo|
|maintainer-tarteo|

This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_timeline>`_ project on GitHub.

Expand Down
2 changes: 2 additions & 0 deletions web_timeline/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Expand Down
5 changes: 4 additions & 1 deletion web_timeline/static/src/js/timeline_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions web_timeline/static/src/js/timeline_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down