Skip to content

[16.0][IMP] mis_builder: allow to export multiple report in one xls#669

Open
AnizR wants to merge 1 commit intoOCA:16.0from
acsone:imp-mis-report-xlsx
Open

[16.0][IMP] mis_builder: allow to export multiple report in one xls#669
AnizR wants to merge 1 commit intoOCA:16.0from
acsone:imp-mis-report-xlsx

Conversation

@AnizR
Copy link
Contributor

@AnizR AnizR commented Jan 16, 2025

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.

@OCA-git-bot
Copy link
Contributor

Hi @sbidoul,
some modules you are maintaining are being modified, check this out!

@AnizR AnizR force-pushed the imp-mis-report-xlsx branch 4 times, most recently from 650a65d to 3392ff4 Compare January 20, 2025 14:56
@sbidoul
Copy link
Member

sbidoul commented Jan 25, 2025

This looks good at first sight.

If we don't have test coverage for this, it might be a good occasion to add some.

@AnizR AnizR force-pushed the imp-mis-report-xlsx branch from 3392ff4 to e81811a Compare January 28, 2025 13:06
@AnizR
Copy link
Contributor Author

AnizR commented Jan 28, 2025

If we don't have test coverage for this, it might be a good occasion to add some.

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.
Note that it doesn't check the content but, there are tests on the computation of the report and its values.

@AnizR AnizR force-pushed the imp-mis-report-xlsx branch from e81811a to ce944fd Compare January 29, 2025 09:38
@AnizR AnizR force-pushed the imp-mis-report-xlsx branch from ce944fd to 8e6ee05 Compare April 3, 2025 10:03
@AnizR AnizR force-pushed the imp-mis-report-xlsx branch from 8e6ee05 to ba28346 Compare June 5, 2025 13:09
@AnizR AnizR force-pushed the imp-mis-report-xlsx branch from ba28346 to 6265544 Compare June 5, 2025 13:11
@github-actions
Copy link

github-actions bot commented Oct 5, 2025

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.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Oct 5, 2025
@sbidoul sbidoul added enhancement and removed stale PR/Issue without recent activity, it'll be soon closed automatically. labels Oct 27, 2025
@github-actions
Copy link

github-actions bot commented Mar 1, 2026

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.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 1, 2026
@AnizR
Copy link
Contributor Author

AnizR commented Mar 2, 2026

@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?

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 8, 2026
Copy link

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_report should check if objects is a list and iterate over it.
  • The method _generate_xlsx_one_report should be called for each instance.
  • The export_xls() in mis_report_instance.py should not remove ensure_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() in export_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 objects vs mis_instance: The refactored code introduces confusion between objects and mis_instance. Ensure all references are consistent and that mis_instance is 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:

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

@sbidoul
Copy link
Member

sbidoul commented Mar 16, 2026

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants