-
-
Notifications
You must be signed in to change notification settings - Fork 528
[19.0] [MIG] queue_job: migrate + tests #840
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: 19.0
Are you sure you want to change the base?
Conversation
Scope: queue_job, test_queue_job only
…config.yaml excluded-addons update\n- Prettier reformat XML/JS/SCSS and pyproject changes\n- Fix ruff UP031 in controllers and job repr/exception
…._ in controller\n- Use self.env._ + lazy %% formatting in models\n- Paginate channel search in autovacuum\n- Avoid raise in unlink; skip root channel\n- Fix tests: avoid search([]) and correct pylint disable id
|
/ocabot migration queue_job |
|
/ocabot migration test_queue_job |
hoangtrann
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.
appreciate all the work you done here! please review the comments since I notice many weird comments and many changes should be in another PR instead of a migration one
… error messages; keep logging/i18n/SQL intact
…(guard remains in ondelete)
…where appropriate
…ncer (#no-search-all)
…locally (#no-search-all)
Reyes4711-S73
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.
LGTM
omarsyscoon
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.
LGTM
- Remove extra space before "model" in value_json for test_decoder_recordset_list_without_user - Align expected string with encoder output to avoid whitespace-only assertion failures - Scope: tests only; no functional changes Co-authored-by: Pieter Paulussen <[email protected]>
ce3a0d3 to
123900c
Compare
Handled in update. |
Handled in update. |
Handled in update. |
I am going to use a similar solution to yours to handle this and not the PR that was suggested above. Thanks. |
Thanks for the review. I’ve updated the PR to use positional arguments for all translated strings to improve i18n flexibility. Regarding the tests: in Odoo 19, demo data isn’t loaded by default during test runs, which caused failures when relying on the demo user, so the tests create a user explicitly to stay deterministic |
|
For extra context, Odoo indeed changed the default for loading demo data in odoo/odoo@eeac3d4. They even explicitly state in the commit message:
I at least would interpret this to mean that part of migrating code to 19 is to rewrite/refactor tests so they no longer depend on demo data. |
mostafabarmshory
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.
@tishmen
@sbidoul
@PieterPaulussen
Please review and approve this PR. We need this branch, and progress is blocked by non-critical issues.
test_queue_job/tests/test_job.py
Outdated
| "company_ids": [(6, 0, [main_company.id])], | ||
| "group_ids": [(6, 0, [group_user.id])], |
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.
@tishmen
@ sbidoul
Please review and approve this PR. We need this branch, and progress is blocked by non-critical issues.
PieterPaulussen
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.
Most of my feedback seems to be either ignored or resolved.
|
This PR has the |
|
@pedrobaeza Sorry for tagging you here again but you are the only one that I know has merge rights. Would you mind merging this? Thanks in advance. |
|
I plan to read the latest comments and re-review soon(ish). Maybe next week. It the meantime, nothing prevents using it, and reporting further issues if any. |
|
@tishmen Well done - all I can really say is, that I'm glad my PR was superseded - 😜 Overall, I really think we should be getting these PRs for migrations through as efficiently as possible. I know everyone has their opinions, and where code has been touched or altered, it is great to aim for perfection, but if the changes are not wrong, if they are not regressive, then there should be no obligation to "improve" during a migration. Nice if it does, but it should not be obligatory. After watching this unfold, I will be VERY uninclined to offer a module migration, as my objective will be to get the module across as is, and correct, not suddenly inheriting everyone else's wishlists... Of course, this does not mean dismissing anyone's reviews or input without due and proper consideration, but the end game of a migration PR seems different for different people.... |
sbidoul
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.
Thanks, this looks great now.
A few last minor things, and one more important one for performance of graph handling in the read_group rewrite.
| if db_name_opt: | ||
| if isinstance(db_name_opt, (list, tuple, set)): | ||
| return list(db_name_opt) | ||
| return [n for n in str(db_name_opt).split(",") if n] |
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.
Does any one know in which case config["db_name"] is not a list? As I read odoo/tools/config.py it seems it's always a list, since it is parsed with _check_comma.
| # Note: no local _patch_method helper; if needed, patch methods | ||
| # directly in _register_hook as shown above. |
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.
| # Note: no local _patch_method helper; if needed, patch methods | |
| # directly in _register_hook as shown above. |
Nit: this comment is not really helpful outside the migration PR.
| index_1 = "queue_job_identity_key_state_partial_index" | ||
| index_2 = "queue_job_channel_date_done_date_created_index" |
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.
nit: these two variables are not helpful, they could be inlined
| ids_per_graph_uuid = { | ||
| group["graph_uuid"]: group["ids"] for group in jobs_groups | ||
| } | ||
| uuids = [uuid for uuid in self.mapped("graph_uuid") if uuid] |
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.
| uuids = [uuid for uuid in self.mapped("graph_uuid") if uuid] | |
| graph_uuids = [uuid for uuid in self.mapped("graph_uuid") if uuid] |
To avoid confusion with job uuids.
| rows = self.env["queue.job"]._read_group( | ||
| [("graph_uuid", "in", uuids)], | ||
| groupby=["graph_uuid"], | ||
| aggregates=["id:recordset"], | ||
| ) | ||
| # rows -> list of tuples: (graph_uuid, recordset) | ||
| for graph_uuid, recs in rows: | ||
| ids_per_graph_uuid[graph_uuid] = recs.ids |
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.
| rows = self.env["queue.job"]._read_group( | |
| [("graph_uuid", "in", uuids)], | |
| groupby=["graph_uuid"], | |
| aggregates=["id:recordset"], | |
| ) | |
| # rows -> list of tuples: (graph_uuid, recordset) | |
| for graph_uuid, recs in rows: | |
| ids_per_graph_uuid[graph_uuid] = recs.ids | |
| ids_per_graph_uuid = dict(self.env["queue.job"]._read_group( | |
| [("graph_uuid", "in", graph_uuids)], | |
| groupby=["graph_uuid"], | |
| aggregates=["id:array_agg"], | |
| )) |
This is simpler and more efficient, as we don't need the recordsets.
| rows = self.env["queue.job"]._read_group( | ||
| [("graph_uuid", "in", graph_uuids)], | ||
| ["graph_uuid"], | ||
| ["__count"], | ||
| ) | ||
| count_per_graph_uuid = {graph_uuid: cnt for graph_uuid, cnt in rows} |
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.
nit, this is probably slightly more efficient than the dict comprehension
| rows = self.env["queue.job"]._read_group( | |
| [("graph_uuid", "in", graph_uuids)], | |
| ["graph_uuid"], | |
| ["__count"], | |
| ) | |
| count_per_graph_uuid = {graph_uuid: cnt for graph_uuid, cnt in rows} | |
| count_per_graph_uuid = dict(self.env["queue.job"]._read_group( | |
| [("graph_uuid", "in", graph_uuids)], | |
| groupby=["graph_uuid"], | |
| aggregates=["__count"], | |
| )) |
|
@sbidoul I will take care of all of the code review comments this weekend. Thanks for your feedback. |
Scope
Summary
Pre-commit
Tests
./odoo/odoo-bin -c odoo.conf -d odoo_queue_pr_queue_job_base_001 --init queue_job,test_queue_job --test-tags="/queue_job,/test_queue_job" --stop-after-init