451
451
flds = fields_to_read[:]
452
452
params.fields2 = fields_to_read[:]
454
result = self.get_grp_data(rpc_obj.read_group(domain, flds, group_by, 0, 0, ctx), flds)
454
data = rpc_obj.read_group(domain, flds, group_by, 0, 0, ctx)
456
result_tmp = [] # List of processed data lines (dictionaries)
457
# Closure to recursively prepare and insert lines in 'result_tmp'
458
# (as much as the number of 'group_by' levels)
459
def process_data(line):
460
domain_line = line.get('__domain', [])
461
grp_by_line = line.get('__context', {}).get('group_by', [])
462
# If there is a 'group_by', we fetch data one level deeper
464
data = rpc_obj.read_group(domain_line, flds, grp_by_line, 0, 0, ctx)
466
line_copy = line.copy()
467
line_copy.update(line2)
468
process_data(line_copy)
469
# If 'group_by' is empty, this means we were at the last level
470
# so we insert the line in the final result
472
result_tmp.append(line)
473
# Prepare recursively the data to export (inserted in 'result_tmp')
474
for data_line in data:
475
process_data(data_line)
476
result = self.get_grp_data(result_tmp, flds)
456
478
if export_format == "excel":
457
479
return self.export_html(params.fields2, result, view_name)