Skip to content
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

[18.0][MIG] base_tier_validation: Migration to 18.0 #992

Open
wants to merge 215 commits into
base: 18.0
Choose a base branch
from

Conversation

xaviedoanhduy
Copy link

@xaviedoanhduy xaviedoanhduy commented Jan 16, 2025

supersedes: #966

changes are follow up from old PR:

  • fix the icon on systray
  • fix the dymanic color alert on list reviewers
  • fix of not recalculating reviewCount when updating review requests (TierReviewService). don't use useState to calculate tierReviewCounter because the service will update services["mail.store"]
  • replaced old-style string interpolation with f-string and placeholder formatting
  • remove old jquery and replace with javascript available objects
  • optimize multi-company rule
  • replace deprecated output directives (t-esc)

@bosd
Copy link
Contributor

bosd commented Jan 16, 2025

Can you place your commits in a separate commit?
As there is also #990. Maybe we can cherry pick to merge these changes into there. If there is any difference.

@xaviedoanhduy
Copy link
Author

xaviedoanhduy commented Jan 16, 2025

Can you place your commits in a separate commit? As there is also #990. Maybe we can cherry pick to merge these changes into there. If there is any difference.

hi @bosd, that commit fixed the icon bug, but i consider that fix as part of PR Migration (because old PR is not yet merged). and author of this PR (#990) also mentioned we have duplicated work, you can read the conversation here: xaviedoanhduy#1 (comment)

@bosd
Copy link
Contributor

bosd commented Jan 16, 2025

Thanks for the clarification. I was getting a bit lost between the migration pr of this module.
Guess it was better to review this one.
Will do so when I have time.

Side note, on this one codecov is red.

Copy link
Contributor

@ivantodorovich ivantodorovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for taking care of this!

There are a few things that need to be corrected, IMO.
Could you check my remarks? 🙏🏻

Thanks!

Comment on lines 21 to 25
review_groups = self.env["tier.review"].read_group(domain, ["model"], ["model"])
for review_group in review_groups:
model = review_group["model"]
Model = self.env[model]
reviews = self.env["tier.review"].search(review_group.get("__domain"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 tip: This could probably be improved by leveraging the private _read_group method, and aggregating ['id:recordset'], and thus not needing to do a search afterwards

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivantodorovich Good spot. that was on my mind as well.
There are some more places in the code of this module where the orm is flooded by searches from within a for loop.

The _read_group method was introduced in the orm in V17.
IMO that improvement could go into V17 and be forward ported here. Should not be blocking for this pr.

(But I've been told, there is even a more improved method in the V18 orm. But I don't know the details or have looked into that one.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think :recordset was added in 18.0.
In 17.0 a similar thing can be accomplished with :array_agg, and then browsing the list of ids.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, _read_group and ir.recordset already exist in version 17.0, see: odoo/odoo#110737

and by the way I also applied the above code improvement from your suggestion, thank @ivantodorovich

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xaviedoanhduy Thanks!
Actually there are still some places in the code where a search is performed inside a for loop.
(Bad practice for performance.)
https://github.com/OCA/server-ux/pull/992/files#diff-7cca2e2b43a392c79d13759687633b9d88cfe56e6c2238b762e2c8d461690607R123-R124

Maybe you can attend to this, or put it on the roadmap.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, _read_group and ir.recordset already exist in version 17.0, see: odoo/odoo#110737

Oh, indeed. Thanks!

base_tier_validation/models/tier_review.py Outdated Show resolved Hide resolved
base_tier_validation/models/tier_review.py Outdated Show resolved Hide resolved
base_tier_validation/models/tier_validation.py Outdated Show resolved Hide resolved
base_tier_validation/models/tier_validation.py Outdated Show resolved Hide resolved
base_tier_validation/models/tier_validation.py Outdated Show resolved Hide resolved
base_tier_validation/models/tier_validation.py Outdated Show resolved Hide resolved
base_tier_validation/models/tier_validation.py Outdated Show resolved Hide resolved
base_tier_validation/models/tier_validation.py Outdated Show resolved Hide resolved
Copy link

@miikanissi miikanissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test looks good to me - no issues found

@xaviedoanhduy xaviedoanhduy force-pushed the 18.0-mig-base_tier_validation branch from bc507f3 to 3108668 Compare January 17, 2025 11:46
Copy link
Contributor

@bosd bosd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts and work on this: 👍

Functional test:

Colors are not showing in review bar as mentioned by @celm1990 in #990 (review)

@xaviedoanhduy
Copy link
Author

xaviedoanhduy commented Jan 21, 2025

Thanks for your efforts and work on this: 👍

Functional test:

Colors are not showing in review bar as mentioned by @celm1990 in #990 (review)

hi, color issue on reviewers list has been fixed. thanks for the tests

@xaviedoanhduy xaviedoanhduy requested a review from bosd January 21, 2025 01:19
Copy link
Contributor

@bosd bosd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funcitonal test. LGTM 👍

Non-blocking / nitpicking.
JS error/warning
image

UI can be improved a bit.
image

core:
image

@sebalix
Copy link
Contributor

sebalix commented Jan 22, 2025

/ocabot migration base_tier_validation

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Jan 22, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Jan 22, 2025
17 tasks
@xaviedoanhduy xaviedoanhduy force-pushed the 18.0-mig-base_tier_validation branch from 60977bf to 9aedf95 Compare January 23, 2025 09:42
mymage and others added 25 commits January 23, 2025 16:42
Currently translated at 100.0% (143 of 143 strings)

Translation: server-ux-17.0/server-ux-17.0-base_tier_validation
Translate-URL: https://translation.odoo-community.org/projects/server-ux-17-0/server-ux-17-0-base_tier_validation/it/
Previous implementation was losing fields in some cases; new one
properly merges dicts/tuples.

This fixes odd "Missing field string information" errors in
form-embedded lists.

This cset also removes an obsolete `base_model_name` context key no
longer used in Odoo 16.

This cset adds a `test_get_view` test which checks for that
`need_validation` field; it was failing with the previous impl.

Fixes OCA#825.
Computed fields bypass `write`, so we need to override `_write` for that case.
Also, the current value before the update needs to be fetched from the database
because the new value is already set in the cache.
I just realized that a new author was added to the module during an
improvement that merged the functionality of base_tier_validation_waiting.
This was overlook during my review and not explicitly accepted. There
have been many contributors adding new functionalities and this one
was not specially big to be included as author.
TierReview status "waiting" has been added and is the default. Modified the
tier review reminder search domain to accommodate
invalidate_cache() replaced with invalidate_recordset()
Currently translated at 100.0% (150 of 150 strings)

Translation: server-ux-17.0/server-ux-17.0-base_tier_validation
Translate-URL: https://translation.odoo-community.org/projects/server-ux-17-0/server-ux-17-0-base_tier_validation/it/
@xaviedoanhduy xaviedoanhduy force-pushed the 18.0-mig-base_tier_validation branch from 9aedf95 to e7545d3 Compare January 23, 2025 09:42
@xaviedoanhduy
Copy link
Author

Funcitonal test. LGTM 👍

Non-blocking / nitpicking. JS error/warning ![image](https://private-user-images.githubusercontent.com/11499387/405347355-

hi @bosd, I'm not sure the error from your dev tool comes from this module.

I also took this opportunity to improve the interface a bit.

image

@bosd
Copy link
Contributor

bosd commented Jan 23, 2025

Thanks, If you want, you can include #991

Copy link
Contributor

@celm1990 celm1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor change and let's go.
Additionally, please squash the administrative commits a bit. Thanks for the effort!

Comment on lines +20 to +32
onToggleCollapse(ev) {
const panelHeading = ev.currentTarget.closest(".panel-heading");
const collapseDiv = panelHeading.nextElementSibling.matches("div#collapse1")
? panelHeading.nextElementSibling
: null;
if (!collapseDiv) return;
this.state.collapse = !this.state.collapse;
if (this.state.collapse) {
collapseDiv.style.display = "none";
} else {
collapseDiv.style.display = "block";
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first time you click the widget, it does not open; a second click is needed to collapse it. Please take a look. On the second attempt, it works fine, but if you refresh the view again, it doesn't work. I think the initial state might be related.

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.