From 189017d10cc9c94eaae631d25630a5ef6d330cc5 Mon Sep 17 00:00:00 2001 From: "Nasreddin Boulif (bon)" Date: Wed, 5 Jul 2023 04:44:18 +0000 Subject: [PATCH] [FIX] web: allow exporting record with properties when grouped Steps to reproduce: - Install `CRM` for test purpose - Go to `CRM > Pipeline` and open any lead - Add a new property and set a value - Go back and open list view - Group by `Salesperson` - Select all records and click on `Export` in action menu - Add 'Properties' field - Export Issue: Traceback raised. No issue if not grouped. Cause: The properties value is a list of dict. When grouped, the properties value is not converted to string (like it is done for list and tuples in the non-grouped flow). Solution: Move the code that convert list and tuples to string in the non-grouped flow directly to the `write_cell` method so that it is applied in both cases. opw-3338564 closes odoo/odoo#128682 X-original-commit: f380c56bb13773eee0e19462ba7283b04d54183b Signed-off-by: Julien Castiaux (juc) --- addons/web/controllers/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/export.py b/addons/web/controllers/export.py index 0d595596205..9fbef242da4 100644 --- a/addons/web/controllers/export.py +++ b/addons/web/controllers/export.py @@ -224,6 +224,8 @@ class ExportXlsxWriter: cell_value = pycompat.to_text(cell_value) except UnicodeDecodeError: raise UserError(_("Binary fields can not be exported to Excel unless their content is base64-encoded. That does not seem to be the case for %s.", self.field_names)[column]) + elif isinstance(cell_value, (list, tuple)): + cell_value = pycompat.to_text(cell_value) if isinstance(cell_value, str): if len(cell_value) > self.worksheet.xls_strmax: @@ -585,8 +587,6 @@ class ExcelExport(ExportFormat, http.Controller): with ExportXlsxWriter(fields, len(rows)) as xlsx_writer: for row_index, row in enumerate(rows): for cell_index, cell_value in enumerate(row): - if isinstance(cell_value, (list, tuple)): - cell_value = pycompat.to_text(cell_value) xlsx_writer.write_cell(row_index + 1, cell_index, cell_value) return xlsx_writer.value