Skip to content

[ADD] om_excel_reports: Excel export of reports - #211

Merged
github-actions[bot] merged 1 commit into
odoomates:20.0from
akshaymanoj87:20.0-add-om_excel_reports
Nov 1, 2026
Merged

github-actions[bot] merged 1 commit into
odoomates:20.0from
akshaymanoj87:20.0-add-om_excel_reports

Conversation

@akshaymanoj87

Copy link
Copy Markdown
Contributor

What and why

Adds om_excel_reports (Odoo2XL - Odoo Excel Reports) for 20.0: any PDF report can be exported as a real Excel spreadsheet from the Print flow, generated on the server.

This addresses the review feedback sent to the contributor by e-mail:

  • The "(Excel)" Print-menu records are now optional and off by default (system parameter om_excel_reports.print_menu_entries), so no extra report record is created per PDF report.
  • Removed the leftover clearOldPreferences() from report_excel_handler.js.
  • Ruff fixes: import order in controllers/main.py, zip(strict=), extra parentheses, unused noqa, long line.
  • Split _add_table, _all_lines and write_workbook in lib/html_to_xlsx.py into smaller functions (output checked as identical on sample reports).
  • README.md replaced by README.rst with the Credits section.

How to test

  1. Install om_excel_reports on a fresh database.
  2. Print any PDF report (for example from Invoices or Contacts): the PDF / Excel / Both / Preview chooser appears; choose Excel and open the file.
  3. Set the system parameter om_excel_reports.print_menu_entries to 1: an "(Excel)" entry appears in each Print menu. Set it to 0: the entries disappear.

Versions

Branch 20.0. Backports to 18.0 and 19.0 will follow after this is merged, if wanted.

@odoomates

Copy link
Copy Markdown
Owner

Hi @akshaymanoj87, thank you for the updates!

The converter is missing. CI cannot load the module yet: om_excel_reports/lib/html_to_xlsx.py is not in the branch. The repository's .gitignore ignores every folder named lib/, so git left the converter out of your commit without a warning. Could you push it, ideally under another folder name (for example om_excel_reports/converter/), so that it cannot be ignored again? We will also narrow that .gitignore rule on our side.

What we will change next. Once CI is green, we will push one commit to your branch ourselves (thanks for allowing edits from maintainers), to keep the module small and free of interference with other modules:

  1. Drop the "(Excel)" Print-menu companions. The PDF / Excel / Both dialog already offers Excel on every PDF report, so the companion reports are not needed. This removes:

    • the fields of ir.actions.report: the excel report type, excel_enabled, excel_source_id, excel_ids and excel_pdf_report, and their form view;
    • the code that keeps the companions in step with their PDF report (create, write, sync);
    • the overrides of _get_report_from_name and _get_report, which change how every report in the database is looked up;
    • the om_excel_reports.print_menu_entries system parameter.

    The module then no longer changes ir.actions.report at all.

  2. No dialog where a dedicated Excel export exists. A PDF report whose model already has an xlsx report (for example our Accounting Excel Reports) keeps its own Excel button, so the user does not get two Excel versions of the same report.

The dialog, the preview, the download routes and your converter stay as they are. We will explain the commit here when we push it, and the PR will be squashed into a single commit when merged, under your name.

@akshaymanoj87
akshaymanoj87 force-pushed the 20.0-add-om_excel_reports branch from c21e375 to 6222737 Compare November 1, 2026 09:02
odoomates added a commit that referenced this pull request Nov 1, 2026
The Python template ignored every folder named lib/, build/, dist/,
var/... anywhere in the tree, which also hid the folders of the
modules: a module's lib/ (the converter of om_excel_reports, #211 of
odooapps) or static/lib/ was left out of the commits without a warning.
These folders are now ignored at the root of the repository only.
@odoomates

Copy link
Copy Markdown
Owner

Update @akshaymanoj87: we have fixed the .gitignore on 20.0 (12b079b): the packaging folders such as lib/ are now ignored at the root of the repository only, no longer inside a module.

So you can keep the converter where it is: please merge 20.0 into your branch (or rebase on it) and commit om_excel_reports/lib/html_to_xlsx.py as it is, no need to rename the folder. Thanks!

@akshaymanoj87
akshaymanoj87 force-pushed the 20.0-add-om_excel_reports branch from 6222737 to ffd4837 Compare November 1, 2026 09:34
@odoomates

odoomates commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Hi @akshaymanoj87, thanks for pushing the converter (ffd48372), CI is running on it now.

We would be happy if you could make these two changes yourself, in your single commit:

1. Remove the "(Excel)" Print-menu duplicates
The PDF / Excel / Both / Preview dialog already offers Excel on every PDF report, so the duplicate report records are not needed. Please remove:

  • in models/ir_actions_report.py, the fields report_type (the 'excel' value), excel_enabled, excel_source_id, excel_ids and excel_pdf_report;
  • the companion code: _excel_menu_entries_enabled, _excel_companion_vals, _excel_companion_wanted, _excel_companion_changes, _sync_excel_companions, _sync_all_excel_companions, and the create / write overrides;
  • the overrides of _get_report_from_name and _get_report: they change how every report in the database is looked up;
  • models/ir_config_parameter.py (the print_menu_entries parameter) and views/ir_actions_report_views.xml;
  • in report_excel_handler.js, the branch for action.report_type === "excel";
  • the tests and the tour (excel_print_menu.js) of the Print-menu entries, and their mention in the README.

The module then no longer changes ir.actions.report at all. _render_excel, the routes, the dialog, the preview and the converter stay.

2. No overlap with other Excel report modules
Some reports already have their own Excel export: our paid Accounting Excel Reports, and modules built on report_xlsx. They use report actions of type xlsx on the same model as the PDF report. For those reports, the dialog should not appear, so the user does not get two Excel versions of the same report. In the excel_allowed route (controllers/main.py):

report = request.env['ir.actions.report']._get_report_from_name(report_name)
dedicated = report and request.env['ir.actions.report'].sudo().search_count(
    [('model', '=', report.model), ('report_type', '=', 'xlsx')], limit=1)
allowed = bool(report and is_pdf_report_type(report.report_type) and not dedicated)

Please keep _render_excel refusing a report that is not a PDF report. Keep your excel converter and /report/excel/ URL as they are, separate from the xlsx ones; keep calling super() in the controller for the other types, and returning false in the JS handler for actions you do not handle.

A test for this would be welcome: create an xlsx report action on the model of a PDF report (skip the test when no module adds the xlsx report type), and check that excel_allowed returns allowed: False for that PDF report and True for the others.

As before: one commit, CI green, no warning in the logs. When merged, the PR will be squashed into a single commit under your name.

Thanks!

@akshaymanoj87
akshaymanoj87 force-pushed the 20.0-add-om_excel_reports branch 2 times, most recently from ffd4837 to d28ce77 Compare November 1, 2026 10:02
@odoomates

Copy link
Copy Markdown
Owner

Hi @akshaymanoj87, thanks a lot for the update: the Print-menu entries are gone and the dialog now steps aside for reports with their own Excel export, exactly as we hoped. CI is green.

Two small things before we merge, both in your single commit:

1. Manifest (__manifest__.py)

  • Please remove the line Contributor: Akshay Manoj. from the description: your credit lives in the README, as agreed.
  • The end of the description and the license are on one line (""", 'license': 'LGPL-3',). Please put 'license': 'LGPL-3', on its own line.

2. README (README.rst)

  • Under Contributors, please write your name as a list item, as in our other modules:

    Contributors
    ------------
    
    * Akshay Manoj

Then amend your commit and force-push. That push will also run our new commit messages check, which is now required and hasn't run on this PR yet (your commit message already follows the format). Thanks again!

@akshaymanoj87
akshaymanoj87 force-pushed the 20.0-add-om_excel_reports branch from d28ce77 to 169c0f1 Compare November 1, 2026 12:33
@mehjabinfarsana

Copy link
Copy Markdown
Collaborator

/mergebot r+

@github-actions
github-actions Bot merged commit 2fbefe4 into odoomates:20.0 Nov 1, 2026
2 checks passed
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Merging now.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

🎉 Merged, thank you @akshaymanoj87!

That makes 2 of your pull requests merged at Odoo Mates: thank you for coming back.

Kudos for [ADD] om_excel_reports: Excel export of reports 👏

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants