Before this commit if another app crashes the "report_xlsx" controller it would go into the exception.
However in the exception the following is called:
_logger.exception("Error while generating report %s", reportname)
As the except clause does not have the "reportname" variable it fails:
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/src/odoo/odoo/http.py", line 804, in dispatch
r = self._call_function(**self.params)
File "/home/odoo/src/odoo/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 910, in __call__
return self.method(*args, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/home/odoo/src/user/report_xlsx/controllers/main.py", line 100, in report_download
_logger.exception("Error while generating report %s", reportname)
Exception
By putting the "reportname" before the try it will always be available
the report handler for xlsx added over here is always returning `true` even if the report being
generated is not xlsx. Due to this, the report handler doesn't check for other report types
at b309d3a99f/addons/web/static/src/webclient/actions/action_service.js (L1019)
and thus doesn't generate any other reports. So if the converter is not xlsx, return false instead of true.
Also, updating the docids and context in the report_routes controller only needs to be done if
the converter is xlsx and not in any other case.
Before this commit, when exception is raised while generating report,
on browser window instead of python traceback nothing was shown
on production environment or werkzeug's "Console locked" message
on development environment.
We want to avoid duplicated sheet names exceptions the same following the same
philosophy that Odoo implements overriding the main library to avoid the 31
characters limit triming the strings before sending them to the library.
In some cases, there's not much control over this as the reports send automated
data and the potential exception is hidden underneath making it hard to debug
the original issue. Even so, different names can become the same one as their
strings are trimmed to those 31 character limit.
This way, once we come across with a duplicated, we set that final 3 characters
with a sequence that we evaluate on the fly. So for instance:
- 'Sheet name' will be 'Sheet name~01'
- The next 'Sheet name' will try to rename to 'Sheet name~01' as well and then
that will give us 'Sheet name~02'.
- And the next 'Sheet name' will try to rename to 'Sheet name~01' and then to
'Sheet name~02' and finally it will be able to 'Sheet name~03'.
- An so on as many times as duplicated sheet names come to the workbook up to
100 for each sheet name. We set such limit as we don't want to truncate the
strings too much and keeping in mind that this issue don't usually ocurrs.
TT31938