[ADD] util/report: util.add_report#360
Conversation
cc49acd to
7dae849
Compare
|
upgradeci retry with always only crm |
aj-fuentes
left a comment
There was a problem hiding this comment.
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
3525d5d to
7b3739f
Compare
c48c6f9 to
64d430b
Compare
d168aff to
4c0c518
Compare
3587982 to
a0ba44f
Compare
7a97a4a to
3036c32
Compare
3036c32 to
bba2e7f
Compare
|
upgradeci retry |
| total = len(data) if total is None else total | ||
| limit = min(limit, total) if limit != -1 else total | ||
| disclaimer = "The total number of affected records is {}.".format(total) |
There was a problem hiding this comment.
I think we shouldn't be explicit about the total unless it is explicitly passed. The reason is that maybe the caller just passed here a subset of the involved records in data, we cannot be sure that's the actual total number of affected records unless explicitly set.
| total = len(data) if total is None else total | |
| limit = min(limit, total) if limit != -1 else total | |
| disclaimer = "The total number of affected records is {}.".format(total) | |
| disclaimer = "The total number of affected records is {}.".format(total) if total else "" | |
| total = len(data) if total is None else total | |
| limit = min(limit, total) if limit != -1 else total |
9382655 to
670685e
Compare
|
@aj-fuentes your latest suggestion is applied. Rebase not necessary because it's still up to date. |
670685e to
9382655
Compare
|
upgradeci retry |
|
@aj-fuentes @KangOl it's ready for another look. |
|
upgradeci retry |
| link: get_anchor_link_to_record(rec_model, row_dict[id_col], row_dict[name_col]) | ||
| for link, (rec_model, id_col, name_col) in links.items() | ||
| } | ||
| ) |
There was a problem hiding this comment.
Once we generate the link items (which are already escaped) I think we need to escape the remaining values in the dict.
For example imagine that row_format is "{some_field}" and in the dict we get {"some_field": "<script>window.alert('escaped')</script>"}
| ) | |
| ) | |
| row_dict = {col: html_escape(val) for col, val in row_dict.items()} |
cc: @KangOl
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.
Use the new utility function designed specifically for adding a report with a list of records.

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):