Skip to content
Browse files

[FIX] base export: Manage False in groupby title

Before this commit, when we export a list with a groupby on
boolean, the groupby title 'False' is replaced by 'Undefined'
in xls document.

After this commit, with an export and groupby on a boolean, we
will have correct title: True and False.
  • Loading branch information...
jbm-odoo committed Oct 9, 2019
1 parent 4ad7a99 commit ab8745671621360733b942fe85f97c052721542d
Showing with 10 additions and 4 deletions.
  1. +10 −4 addons/web/controllers/
@@ -584,10 +584,11 @@ class GroupsTreeNode:
build a leaf. The entire tree is built by inserting all leaves.

def __init__(self, model, fields, groupby, root=None):
def __init__(self, model, fields, groupby, groupby_type, root=None):
self._model = model
self._fields = fields
self._groupby = groupby
self._groupby_type = groupby_type

self.count = 0 # Total number of records in the subtree
self.aggregated_values = Counter() # Fields aggregated values {field_name: aggregated value}
@@ -605,7 +606,7 @@ def child(self, key):
:return: the child node
if key not in self.children:
self.children[key] = GroupsTreeNode(self._model, self._fields, self._groupby)
self.children[key] = GroupsTreeNode(self._model, self._fields, self._groupby, self._groupby_type)
return self.children[key]

def insert_leaf(self, group):
@@ -710,7 +711,9 @@ def __init__(self, fields, row_count=0):
self.fields = fields

def write_group(self, row, column, group_name, group, group_depth=0):
group_name = group_name[1] if isinstance(group_name, tuple) and len(group_name) > 1 else group_name or _("Undefined")
group_name = group_name[1] if isinstance(group_name, tuple) and len(group_name) > 1 else group_name
if group._groupby_type[group_depth] != 'boolean':
group_name = group_name or _("Undefined")
row, column = self._write_group_header(row, column, group_name, group, group_depth)

# Recursively write sub-groups
@@ -1748,13 +1751,16 @@ def base(self, data, token):

Model = request.env[model].with_context(**params.get('context', {}))
groupby = params.get('groupby')
group_type = request.env['ir.model.fields'].read_group([('model', '=', Model._name), ('name', 'in', groupby)], ['name', 'ttype'], ['name', 'ttype'], lazy=False)
group_type_dict = dict((x['name'], x['ttype']) for x in group_type)
groupby_type = [group_type_dict[x] for x in groupby]
if not import_compat and groupby:
domain = [('id', 'in', ids)] if ids else domain
groups_data = Model.read_group(domain, field_names, groupby, lazy=False)

# read_group(lazy=False) returns a dict only for final groups (with actual data),
# not for intermediary groups. The full group tree must be re-constructed.
tree = GroupsTreeNode(Model, field_names, groupby)
tree = GroupsTreeNode(Model, field_names, groupby, groupby_type)
for leaf in groups_data:

0 comments on commit ab87456

Please sign in to comment.
You can’t perform that action at this time.