From be8bbc2396a494a8f22a9d1671891536a7f92abd Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 20 Sep 2016 13:48:47 +0200 Subject: [PATCH] [FIX] base: traceback in `read_group` An issue originally occurs in the Event module. - Go to Events >> Reports >> Events - Add a "Group By" in the search view: "Event Month" - A mighty traceback pops up This is because the rows and the columns are grouped by the same field (`event_date:month`). In method `_read_group_format_result`, a group_by of type "date" or "datetime" is replaced by a "(range_start/range_end, label)" tuple. The first element of the loop on `annotated_groupbys` is handled correctly, but the next identical element will crash on `value + gb['interval']`, since `value` is now a tuple and not a date/datetime anymore. opw-686242 --- openerp/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/models.py b/openerp/models.py index 6702ba9cb1d..8317039705c 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -2209,7 +2209,7 @@ class BaseModel(object): context = context result = self._read_group_raw(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby, lazy=lazy) - groupby = [groupby] if isinstance(groupby, basestring) else groupby + groupby = [groupby] if isinstance(groupby, basestring) else list(OrderedSet(groupby)) dt = [ f for f in groupby if self._fields[f.split(':')[0]].type in ('date', 'datetime') @@ -2234,7 +2234,7 @@ class BaseModel(object): query = self._where_calc(cr, uid, domain, context=context) fields = fields or self._columns.keys() - groupby = [groupby] if isinstance(groupby, basestring) else groupby + groupby = [groupby] if isinstance(groupby, basestring) else list(OrderedSet(groupby)) groupby_list = groupby[:1] if lazy else groupby annotated_groupbys = [ self._read_group_process_groupby(cr, uid, gb, query, context=context)