From d0bf6192d2091d1b7eb4c1cc771b46e34e6c78ac Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 10 Aug 2020 13:52:49 +0000 Subject: [PATCH] [IMP] web: sample data: generate better activities The SampleServer picks a random value for selection fields. As a consequence, field 'activity_exception_decoration' is always set, either to 'warning' or 'danger'. When this field is set, widget 'ListActivity' (set on 'activity_ids') displays 'Warning', whatever the value of 'activity_ids'. This means that with sample data, the next activity field always displays "Warning", which is not great. This special case has been handled in web, as it is the first (and only) one. In the future, if we have to implement several special cases like that, we'll setup a proper hook to allow external modules to define them from the outside. Task 2316726 closes odoo/odoo#55703 Signed-off-by: Mathieu Duckerts-Antoine --- addons/web/static/src/js/views/sample_server.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/web/static/src/js/views/sample_server.js b/addons/web/static/src/js/views/sample_server.js index f6c0ca7903a..d5732aa979a 100644 --- a/addons/web/static/src/js/views/sample_server.js +++ b/addons/web/static/src/js/views/sample_server.js @@ -254,6 +254,15 @@ odoo.define('web.SampleServer', function (require) { return [...new Set(ids)]; } case "selection": { + // I hoped we wouldn't have to implement such special cases, but here it is. + // If this (mail) field is set, 'Warning' is displayed instead of the last + // activity, and we don't want to see a bunch of 'Warning's in a list. In the + // future, if we have to implement several special cases like that, we'll setup + // a proper hook to allow external modules to define extensions of this function. + // For now, as we have only one use case, I guess that doing it here is fine. + if (fieldName === 'activity_exception_decoration') { + return false; + } if (field.selection.length > 0) { return this._getRandomArrayEl(field.selection)[0]; }