Skip to content

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

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

Merged
merged 216 commits into from
Feb 4, 2025

Conversation

xaviedoanhduy
Copy link
Contributor

@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
  • optimize using new API ORM _read_group for better performance
  • 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
Contributor 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

@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"))

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

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
Contributor 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.

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hello, I've improved some search functions that are called in several loops into a separate commit

Copy link
Contributor

@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
Contributor 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
26 tasks
@xaviedoanhduy xaviedoanhduy force-pushed the 18.0-mig-base_tier_validation branch 2 times, most recently from 9aedf95 to e7545d3 Compare January 23, 2025 09:42
@xaviedoanhduy
Copy link
Contributor 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 31
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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@xaviedoanhduy could you please check this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @celm1990, in my country it is Lunar New Year. I will start working again on 02/03/2025. Thank you for raising the issue and btw happy Lunar New Year 2025

Copy link
Contributor

Choose a reason for hiding this comment

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

Happy lunar year! The year of intelligence and love

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @bosd and @celm1990, the issue of clicking twice on the widget when loading the page for the first time has been resolved

@xaviedoanhduy xaviedoanhduy force-pushed the 18.0-mig-base_tier_validation branch from e7545d3 to a01b6d5 Compare February 3, 2025 08:37
@xaviedoanhduy xaviedoanhduy force-pushed the 18.0-mig-base_tier_validation branch from a01b6d5 to 4c6095b Compare February 3, 2025 08:42
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.

Tested locally, LGTM.

Just a non-blocking comment: I think it's possible to squash the administrative commits a bit, following this guide: Merge commits in pull requests.

Thanks for the effort!

ping @sebalix @LoisRForgeFlow @pedrobaeza

Copy link
Member

@StefanRijnhart StefanRijnhart left a comment

Choose a reason for hiding this comment

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

Thanks everyone, great work here on the review and the follow up!

@StefanRijnhart
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 18.0-ocabot-merge-pr-992-by-StefanRijnhart-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Feb 4, 2025
Signed-off-by StefanRijnhart
@OCA-git-bot
Copy link
Contributor

@StefanRijnhart your merge command was aborted due to failed check(s), which you can inspect on this commit of 18.0-ocabot-merge-pr-992-by-StefanRijnhart-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@StefanRijnhart
Copy link
Member

Merge failed on OCA/oca-addons-repo-template#291. Doh!

@StefanRijnhart
Copy link
Member

Let's try again after this hour long scheduled brownout

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-992-by-StefanRijnhart-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit b2d6731 into OCA:18.0 Feb 4, 2025
5 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 7526531. Thanks a lot for contributing to OCA. ❤️

@bosd
Copy link
Contributor

bosd commented May 8, 2025

Thanks for the team work on this migration!

Is any of you using this one already in production?
Have you encountered the following bugs in V18:

@miikanissi
Copy link
Contributor

Thanks for the team work on this migration!

Is any of you using this one already in production? Have you encountered the following bugs in V18:

We are using this in production. We have noticed a few issues.

  • Some computed and/or related fields that change after validation can trigger an under validation exception. This can also happen if some fields are written by an action. This sounds like the same issue as the unable to send email issue. Essentially, nothing can change on the record after validation. We have fixed this by just adding a ton of fields in the validation exceptions rules.
  • Readonly fields configured in the field definition are editable. For example, the date_approve field on a Purchase Order is a readonly field in the field definition. But after setting up validations the field will be editable. We had to manually make a view level change to set readonly="1" on the affected fields. TLDR; Readonly Field definition is ignored.

@LoisRForgeFlow
Copy link
Contributor

Thanks for the team work on this migration!
Is any of you using this one already in production? Have you encountered the following bugs in V18:

We are using this in production. We have noticed a few issues.

  • Some computed and/or related fields that change after validation can trigger an under validation exception. This can also happen if some fields are written by an action. This sounds like the same issue as the unable to send email issue. Essentially, nothing can change on the record after validation. We have fixed this by just adding a ton of fields in the validation exceptions rules.
  • Readonly fields configured in the field definition are editable. For example, the date_approve field on a Purchase Order is a readonly field in the field definition. But after setting up validations the field will be editable. We had to manually make a view level change to set readonly="1" on the affected fields. TLDR; Readonly Field definition is ignored.

@miikanissi Thanks for the heads-up.

It looks like there is not feedback from the migrator and reviewers in v18. If your comments are still applicable, I would kindly ask you to create issues in this repository to track the problem. Otherwise this comment will be forgotten here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.