[16.0][IMP] mis_builder: allow to export multiple report in one xls#669
[16.0][IMP] mis_builder: allow to export multiple report in one xls#669
Conversation
|
Hi @sbidoul, |
650a65d to
3392ff4
Compare
|
This looks good at first sight. If we don't have test coverage for this, it might be a good occasion to add some. |
3392ff4 to
e81811a
Compare
There's already a test that checks that it is possible to generate a xlsx report. I've added a small one for generation of a report over 2 instances. |
e81811a to
ce944fd
Compare
ce944fd to
8e6ee05
Compare
8e6ee05 to
ba28346
Compare
ba28346 to
6265544
Compare
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
|
@sbidoul, I'll soon port this PR in 19. Do you prefer to try have some review here to have it merged then, migrate to 19 or close this PR and open a new one in 19? |
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root cause of the test failure
The test failure occurs because the export_xls() method no longer calls self.ensure_one() and the XLSX report generation logic was refactored to support multiple instances, but the report action is not correctly handling a list of records when multiple instances are passed.
2. Suggested fix
In mis_builder/report/mis_report_instance_xlsx.py, the generate_xlsx_report method must ensure it handles both single and multiple records properly. Specifically:
- The method
generate_xlsx_reportshould check ifobjectsis a list and iterate over it. - The method
_generate_xlsx_one_reportshould be called for each instance. - The
export_xls()inmis_report_instance.pyshould not removeensure_one()unless it's explicitly designed to support multiple records and is handled in the report generation.
File: mis_builder/report/mis_report_instance_xlsx.py
Method: generate_xlsx_report
Lines: Around 37–40 and 192–195
Fix: Ensure generate_xlsx_report handles list of objects correctly and calls _generate_xlsx_one_report for each.
def generate_xlsx_report(self, workbook, data, objects):
if not isinstance(objects, models.BaseModel):
objects = self.env["mis.report.instance"].browse(objects)
for instance in objects:
self._generate_xlsx_one_report(workbook, instance)Also, in mis_builder/models/mis_report_instance.py, the export_xls() method must keep self.ensure_one() to ensure it's only called on a single record, unless the intent is to support multi-record export via a different mechanism.
3. Additional code issues
- Missing
ensure_one()inexport_xls(): Although this is a breaking change, it's not necessarily a bug if the intent is to support multi-record export, but the report action must be updated accordingly. - Inconsistent use of
objectsvsmis_instance: The refactored code introduces confusion betweenobjectsandmis_instance. Ensure all references are consistent and thatmis_instanceis always a single record.
4. Test improvements
Add a test case that explicitly tests multi-record export and ensures that the XLSX report works correctly when multiple instances are passed. Use TransactionCase or SavepointCase for proper test isolation.
Suggested test in test_mis_report_instance.py:
def test_xlsx_export_multiple_instances(self):
# Test export of multiple instances
action = self.report_instance.export_xls()
self.assertTrue(action)
# Test that the action correctly handles multiple records
self.report_instance_4.export_xls()Pattern: Use SavepointCase for better isolation if testing complex multi-record scenarios.
Tagging: Use @tag('post_install', 'hardening') for such tests.
⚠️ PR Aging Alert: CRITICAL
This PR by @AnizR has been waiting for 423 days — that is over 14 months without being merged or closed.
Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)
Reciprocal Review Request
Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):
My open PRs across OCA:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
Reviewing each other's work helps the whole community move forward. Thank you!
Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b
|
@marcos-mendez please do not post AI assisted code review in this project. This does not help moving thing forward in any way, on the contrary. |
Description
Allow to export multiple reports at once.
In one '.xls' where every report is a sheet.
To do so, I added one action 'Export XLS' visible on tree view of
mis_report_instance.