Merge PR #1347 into 12.0

Signed-off-by dreispt
pull/1848/head
OCA-git-bot 2021-03-10 08:25:38 +00:00
commit 0df646680c
4 changed files with 16 additions and 7 deletions

View File

@ -66,6 +66,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 (on the current model) that contains the HTML color (e.g. #FFFFFF). This option has priority over 'colors'. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| color-field | No | Allows to set a field (on the current model) that contains the HTML color (e.g. #FFFFFF). This option has priority over 'colors'. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| dependency_arrow | No | Set this attribute to a x2many field to draw arrows between the records referenced in the x2many field. |
+--------------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

View File

@ -421,11 +421,16 @@ odoo.define('web_timeline.TimelineRenderer', function (require) {
} else {
group = -1;
}
_.each(self.colors, function (color) {
if (eval("'" + evt[color.field] + "' " + color.opt + " '" + color.value + "'")) {
self.color = color.color;
}
});
var color = null;
if (self.arch.attrs.color_field !== undefined) {
color = evt[self.arch.attrs.color_field];
} else {
_.each(self.colors, function (col) {
if (eval("'" + evt[col.field] + "' " + col.opt + " '" + col.value + "'")) {
color = col.color;
}
});
}
var content = _.isUndefined(evt.__name) ? evt.display_name : evt.__name;
if (this.arch.children.length) {
@ -438,13 +443,12 @@ odoo.define('web_timeline.TimelineRenderer', function (require) {
'id': evt.id,
'group': group,
'evt': evt,
'style': 'background-color: ' + self.color + ';'
'style': 'background-color: ' + color + ';'
};
// Check if the event is instantaneous, if so, display it with a point on the timeline (no 'end')
if (date_stop && !moment(date_start).isSame(date_stop)) {
r.end = date_stop;
}
self.color = null;
return r;
},

View File

@ -61,6 +61,7 @@ odoo.define('web_timeline.TimelineView', function (require) {
"default_group_by",
"progress",
"date_delay",
"color_field",
];
fieldsToGather.push(attrs.default_group_by);