[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) <juc@odoo.com>
This commit is contained in:
Nasreddin Boulif (bon)
2023-07-17 12:06:33 +02:00
parent 44edf9c9ac
commit 189017d10c
+2 -2
View File
@@ -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