[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
This commit is contained in:
Nicolas Martinelli
2016-09-22 10:21:10 +02:00
parent ab06013e30
commit be8bbc2396
+2 -2
View File
@@ -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)