From 3ea6180f182d6ea06b963fe437be05b380f1ee46 Mon Sep 17 00:00:00 2001 From: "jerome hanke (jhk)" Date: Wed, 26 Feb 2020 12:31:41 +0000 Subject: [PATCH] [FIX] web: export of id from grouped elements does not fail Steps to reproduce: - install sales - go to sales > go to any list view (SO for example) and group by anything (customer for example) - click on action > export > add ID to the exported columns - click export Previous behavior: you get a traceback: "Invalid field specification '.id'." Current behavior: ids are exported as intended opw-2194233 closes odoo/odoo#48222 X-original-commit: c8217080d960ec3f8436111ce60a17754fe64f2d Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: mightyjol --- addons/web/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 1fece767a0d..3b0e2e27f28 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -660,6 +660,8 @@ class GroupsTreeNode: """ Return field names of exported field having a group operator """ aggregated_field_names = [] for field_name in self._export_field_names: + if field_name == '.id': + field_name = 'id' if '/' in field_name: # Currently no support of aggregated value for nested record fields # e.g. line_ids/analytic_line_ids/amount @@ -1857,7 +1859,7 @@ class ExportFormat(object): if not import_compat and groupby: groupby_type = [Model._fields[x.split(':')[0]].type for x in groupby] domain = [('id', 'in', ids)] if ids else domain - groups_data = Model.read_group(domain, field_names, groupby, lazy=False) + groups_data = Model.read_group(domain, [x if x != '.id' else 'id' for x in 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.