-
Notifications
You must be signed in to change notification settings - Fork 81
[ADD] util/report: util.add_report #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
cc49acd to
7dae849
Compare
|
upgradeci retry with always only crm |
aj-fuentes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do some simplification here. Some suggestions below. Note that none of the suggestions were tested, take it as a guide.
b40852a to
3525d5d
Compare
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.
3525d5d to
7b3739f
Compare
| :param List[Tuple] data: Any data in the form of a list of tuples, e.g. the output of cr.fetchall(). | ||
| :param Tuple[str] columns: Arbitrary names for each column in "data". All columns must be named and | ||
| the order of these names must be the same as in "data". | ||
| :param Dict[str, Tuple[str, str, str]] links: Optional model/record links, e.g.: | ||
| { | ||
| "partner_link": ("res.partner", "id", "name"), | ||
| "company_link": ("res.company", "company_id", "company_name"), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Do not use typing format, follow what's done elsewhere in this repo and use the plain type built-ins
- Shorten this and move all examples to a proper example block in the documentation description before the parameters:
.. example::
.. code-block:: python
# code example here
- Always ensure everything renders as expected -> open the documentation CI link, then log in and go to the relevant section of the documentation. This would need a PR in
odoo/documentationto add the automodule forutil.reportand will require revision of all other functions we document here. Target 17.0 - Document the parameters in the same order they are used in the function.
- Use lowercase after the colon (basically follow the format as in other cases here ;))
Some of the above as a suggestion:
| :param List[Tuple] data: Any data in the form of a list of tuples, e.g. the output of cr.fetchall(). | |
| :param Tuple[str] columns: Arbitrary names for each column in "data". All columns must be named and | |
| the order of these names must be the same as in "data". | |
| :param Dict[str, Tuple[str, str, str]] links: Optional model/record links, e.g.: | |
| { | |
| "partner_link": ("res.partner", "id", "name"), | |
| "company_link": ("res.company", "company_id", "company_name"), | |
| } | |
| :param list(tuple) data: data to report, each entry would be a row in the report. | |
| It could be empty, in which case only the summary is redered. | |
| :param tuple(str) columns: names for each column in "data", can be referenced in `row_format`. | |
| :param dict links: optional model/record links spec, the keys can be referenced in `row_format`. |
|
|
||
| if not data: | ||
| row_to_html(columns) # Validate the format is correct, including links | ||
| return report_with_summary(summary=summary, details="No records to display.", category=category) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is better:
| return report_with_summary(summary=summary, details="No records to display.", category=category) | |
| return report_with_summary(summary=summary, details="", category=category) |
then adapt report_with_summary to not add any summary/details structure when details is empty, and just output summary directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better. Please adapt the documentation to the same format we use elsewhere in this repo. Some suggestions above.

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 ofutil.add_to_migration_reports.Example 1
Example 2
Example 3
Example 4
Remaining details to discuss
limit.columns(instead of a tuple) or a dictionary of lists forlinks(instead of a dictionary of tuples).add_to_migration_reports.ir.ui.viewrecord corresponding to the note is sometimes incorrect (previously there was the same issue):