[FIX] web, stock: rollback database when crashing on report generation
Current behaviour: When we are printing a report and then the report fails to generate (for ex. wkhtmltopdf memory limit/timeout), the incorrect state is committed to the database. Expected behaviour: We should rollback when generating reports fails, since it is an error state. Steps to reproduce: To reproduce the behaviour, we need to force an error state. - In odoo/addons/base/models/ir_actions_report.py:`_run_wkhtmltopdf()`, raise an exception before spawning the subprocess (for ex. adding a 1/0). - In addons/web/controllers/main.py:`report_download()`#L2126, add this little code snippet: ```python ids = [int(x) for x in docids.split(",")] report = request.env['ir.actions.report']._get_report_from_name(reportname) obj = request.env[report.model].browse(ids) if getattr(obj, 'message_post'): obj.message_post(body='This report was committed!') ``` - Install Inventory - Pick a delivery order and try to print it, there should be an error (whatever exception you decided to raise in `_run_wkhtmltopdf()`) - See that in the message board we got a message that the report has been committed, which isn't the case, it failed to generate. Reason for the problem: Controllers are catching the exception when generating reports, but never reset the state of the database. Fix: Raise an InternalServerError with an error code of 500 to trigger a database rollback. Affected versions: - 14.0 - 15.0 - saas-15.2 - saas-15.3 - 16.0 - master opw-3001950 closes odoo/odoo#106027 X-original-commit: d7fdcdce Related: odoo/enterprise#34113 Signed-off-by:Julien Castiaux <juc@odoo.com> Signed-off-by:
Piryns Victor (pivi) <pivi@odoo.com>
Loading
Please register or sign in to comment