odoo/upgrade-util#360
Created by Upgrade, Oskar Wielgos (owi)
Blocked
- Merge method
- Review
-
CI
- ci/runbot: Test upgrades between stable versions
- ci/upgrade_enterprise: Test upgrades for enterprise master
- Linked pull requests
- label
- odoo-dev:master-add_report-owi
- head
- 64d430bcc10087d0056c5e93eeef115f4a1bee9c
| odoo/upgrade | odoo/upgrade-util | |
|---|---|---|
| master | #8968 missing r+ | #360 missing r+ |
[ADD] util/report: util.add_report
Add a new function that replaces util.add_to_migration_reports.
The new function can automatically parse the provided data as a list of records. It can also limit the number of displayed records to prevent the upgrade report from growing too large.
The structure of the note is now defined within the function itself, standardizing its appearance.
Example usage
More examples will follow in odoo/upgrade, replacing the existing use of util.add_to_migration_reports.
Example 1
cr.execute(
"""
SELECT p.id, p.name, p.city, p.comment, p.company_id, com.name FROM res_partner p
JOIN res_company com
ON p.company_id = com.id
"""
)
summary = """
This is a test of the utility method that is displaying a list of rows
returned by an SQL query. The number of displayed rows is limited.
"""
row_format = "Partner with id {partner_link} works at company {company_link} in {city}, ({comment})"
columns = ("id", "name", "city", "comment", "company_id", "company_name")
links = {"company_link": ("res.company", "company_id", "company_name"), "partner_link": ("res.partner", "id", "name")}
util.add_report(header="Test of the new utility method", summary=summary, row_format=row_format, columns=columns, links=links, data=cr.fetchall())
<img width="1151" height="635" alt="image" src="https://github.com/user-attachments/assets/64542831-f142-484c-becc-ff200297287a" />
Example 2
util.add_report(header="Simple note", summary="A detailed description of the change.")
<img width="294" height="75" alt="image" src="https://github.com/user-attachments/assets/aea1c9c6-c7d8-4692-aa82-71ff460e0cdf" />
Example 3
msg = """
This is some text in **bold**.
This is a line
that should break.
- Item one
- Item two
- Sub-item
And some _italic_ text.
"""
util.add_report(header="MD note", summary=msg, report_format="md")
<img width="324" height="198" alt="image" src="https://github.com/user-attachments/assets/0c4a9324-cca9-4e4a-834d-ea8ad8d71f63" />
Example 4
msg = """
This is some text in **bold**.
| This is a line
| that should break.
* Item one
* Item two
* Sub-item
And some *italic* text.
"""
util.add_report(header="RST note", summary=msg, report_format="rst")
<img width="411" height="202" alt="image" src="https://github.com/user-attachments/assets/75c92d4e-c1ae-4948-8665-ac4f5c5774ab" />
Remaining details to discuss
- The introduction of env var to control
limit. - Enforce/assert the use of tuples instead of lists. Currently, it's possible to pass a list for
columns(instead of a tuple) or a dictionary of lists forlinks(instead of a dictionary of tuples). - How to handle depreciation of
add_to_migration_reports. - Indentation of the
ir.ui.viewrecord corresponding to the note is sometimes incorrect (previously there was the same issue):
<img width="1527" height="540" alt="image" src="https://github.com/user-attachments/assets/5e9cf10d-2c7f-4898-b842-5bffd1ec231f" />