Solution for Including Multiline Sections in Custom Worksheets in Field Services Reports
If you’ve created custom worksheets in Studio for maintenance tasks in Field Services and the multiline sections aren't displaying correctly in reports (replaced with something like x_project_task_worksheet_template_16_line_fe9aa(2, 3, 4)), here's how you can resolve the issue.
Issue
The custom worksheets created in Studio display correctly in the Odoo interface, but when printing or generating reports, the One2many fields (multiline sections) are not rendered properly. Instead, they appear as technical references, e.g., x_project_task_worksheet_template_16_line_cd368(2, 3, 4).
This happens because the automatically generated templates from Studio don't handle One2many fields directly in the QWeb report.
Solution: Customize the QWeb Template
To fix this issue, you need to manually customize the QWeb template that renders the report for the worksheet. Follow these steps:
- Identify the QWeb Template:
- The automatically generated QWeb template for the worksheet can be found under Settings > Technical > User Interface > Views (enable developer mode if needed).
- Locate the template by its external ID. In this case, it might look like industry_fsm_report.report_custom_x_project_task_worksheet_template_16.
- Modify the Template to Handle One2many Fields:
- Test the Report:
- Save the changes and regenerate the report.
- Check that the multiline sections now display correctly with the expected data.
Explanation
The solution involves manually iterating through the records of the One2many field in the QWeb template using t-foreach. Each row is rendered dynamically based on the values stored in the One2many field, ensuring the data is displayed properly in the report.
Additional Notes
- If the worksheet isn't linked to the project.task model directly, you might need to add a Many2one relation in Studio or via code to associate the worksheet with the task.
- This solution is applicable for any module or report in Odoo where Studio-generated One2many fields aren't displaying correctly.
- For advanced customizations, consider developing a custom Odoo module instead of relying entirely on Studio.
This approach ensures that your custom worksheets will display all multiline sections properly in the reports generated from Field Services tasks. 😊