From b7e2d4759688b4735c789237b0ebafbc2469e34d Mon Sep 17 00:00:00 2001 From: Hiral Bhavsar Date: Mon, 9 Jul 2018 10:20:53 +0530 Subject: [PATCH] [FIX] web: Make progress bar work with selection fields Purpose ======= The progress bar on a kanban column doesn't work with selection fields Specification ============= In kanban view, subgroupCounts of progressbar should work if columns are grouped with a selection field Currently, progressbar's subgroupCounts only worked if column is grouped by a 'Many2one' field. If column is grouped by a 'selection' field then its not working. For example, If column is grouped by a 'Many2one' field then we've tuple, {'state': (2, 'Signatures in Progress')} So, here for preparing progressBar values for subgroupCounts we'll get {Signatures in Progress: {overdue: 0, planned: 0, today: 1}} But for a selection field, we'll have a string 'sent' i.e a technical value, {'state': 'sent'} So here 'group_by_value' as a 'key' will never be matched as we have 'sent' instead of 'Signatures in Progress'. We've a technical value instead of its UI value and dict of subgroupCounts would be based on UI values that's why it'll never find values. To fix this issue we need to set proper 'group_by_value'. That's why added one condition for 'selection' field to gets its value of specific state inside 'read_progress_bar' method. Related to Task: 1862371 --- addons/web/models/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web/models/models.py b/addons/web/models/models.py index edf167df6c9..09e5478caf6 100644 --- a/addons/web/models/models.py +++ b/addons/web/models/models.py @@ -62,6 +62,9 @@ class Base(models.AbstractModel): group_by_value, format=display_date_formats[group_by_modifier], locale=locale) + if field_type == 'selection': + group_by_value = dict(self.fields_get()[group_by]['selection'])[group_by_value] + if type(group_by_value) == tuple: group_by_value = group_by_value[1] # FIXME should use technical value (0)