The RPC_ERROR with an "Arbitrary Uncaught Python Exception" during report export in Odoo 17 Community Edition indicates that something went wrong in the backend logic when generating or serving the report. This is often caused by a misconfiguration or a bug in custom or core Odoo modules. Here’s how you can resolve it:
Step-by-Step Troubleshooting
1. Check Server Logs
- Go to the Odoo server terminal and inspect the logs immediately after reproducing the issue.
- Look for a Python traceback in the logs; it will provide specific information about what failed.
Example:
plaintextCopy codeTraceback (most recent call last):
File "/path/to/odoo/odoo/addons/base/models/ir_actions_report.py", line ...
The logs will often point you to the specific file and line where the issue occurred.
2. Verify Report Templates
- If the report you’re exporting is custom, ensure that the corresponding QWeb template is well-formed.
- Go to Settings > Technical > Reports and verify the report's associated template.
- Common errors include:
- Missing or incorrectly defined t-field tags.
- Syntax errors in QWeb templates (like unclosed tags).
Example of a proper t-field tag:
xmlCopy code<t t-foreach="docs" t-as="o">
<span t-field="o.name"/>
</t>
3. Check the Report Action Configuration
- Navigate to Settings > Technical > Actions > Reports.
- Locate the report you are trying to export.
- Verify that the Template and Model fields are correctly configured.
Example:
- Template: report_saleorder_document
- Model: sale.order
If these are misconfigured, Odoo may fail to generate the report correctly.
4. Inspect Module Dependencies
- If you’re using custom modules, ensure that the dependencies for the report are loaded and correctly defined.
- Check for missing imports or improperly overridden methods in the related report logic (e.g., render_html, render_qweb_pdf).
5. Enable Developer Mode for Debugging
- Enable Developer Mode in Odoo (Settings > Activate Developer Mode).
- Reproduce the issue and check for additional details in the browser console or the /web/assets/debug/ stack traces.
6. Recompile Assets
7. Test on a Clean Environment
- Sometimes, issues are environment-specific. Export the same report on a fresh Odoo instance or database with no customizations.
- If it works, the issue lies in your customizations or data setup.
8. Patch or Debug the Code
9. Upgrade or Reinstall Modules
10. Inspect Report Format and Size
- If you’re exporting a large or complex report (e.g., PDF), the issue could be related to timeouts or memory limits. Increase the timeout in your Odoo configuration:
Example of Fixing QWeb Errors in ir_actions_report
Here’s an example of debugging Python logic in a report:
pythonCopy codefrom odoo import models
class ReportSaleOrder(models.AbstractModel):
_name = 'report.sale.order_report'
def _get_report_values(self, docids, data=None):
try:
docs = self.env['sale.order'].browse(docids)
return {'docs': docs}
except Exception as e:
_logger.error(f"Error generating report: {e}")
raise
Conclusion
By carefully checking logs, templates, and configurations, you should be able to identify the root cause. If the issue persists, please share the exact log error message from the server for more specific guidance.