[FIX] web: fix the traceback

Problem occurs when we try to export report data and click
'I want to update data (import-compatible export)'.
We might end up exporting data when only field to export
is - External ID (id).

To reproduce an issue (for example):
Go to Time Off/Reporting/by Type; Remove filters from search.
Select couple records, then Action/Export.
On the wizard, click on 'I want to update data (import-compatible export)'.
Click on External ID from 'Available fields' to add it to 'Fields to export'.
Click export.

It gives traceback -
File "/data/build/odoo/addons/web/controllers/main.py", line 710,
 in write_header self.worksheet.set_column(0, i, 30) # around 220 pixels
UnboundLocalError: local variable 'i' referenced before assignment

task - 2687370

closes odoo/odoo#84191

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
sofiagvaladze
2022-02-11 13:21:02 +00:00
parent f6a9895d62
commit 41ad15b761
+1 -1
View File
@@ -720,7 +720,7 @@ class ExportXlsxWriter:
# Write main header
for i, fieldname in enumerate(self.field_names):
self.write(0, i, fieldname, self.header_style)
self.worksheet.set_column(0, i, 30) # around 220 pixels
self.worksheet.set_column(0, max(0, len(self.field_names) - 1), 30) # around 220 pixels
def close(self):
self.workbook.close()