[16.0][IMP] sale_triple_discount: Improves perfs and consistency#3329
Merged
OCA-git-bot merged 1 commit intoOCA:16.0from Oct 16, 2024
Merged
[16.0][IMP] sale_triple_discount: Improves perfs and consistency#3329OCA-git-bot merged 1 commit intoOCA:16.0from
OCA-git-bot merged 1 commit intoOCA:16.0from
Conversation
Contributor
Author
|
ping @renda-dev @toita86 @technativa |
When computing the amount total on a sale.order.line, we now avoid to play with the cache since this change introduced in OCA@e3e59ba introduces a decline in performance. When the cache in invalidated, fields are flushed to the database and depending computed fields are recomputed..... This ultimately leads to temporary inconsistencies breaking others addons relaying on this one. Moreover, the method used in this original commit 'self.invalidate_cache(fnames=self._discount_fields(), ids=self.ids)' is deprecated and the use of the recommended new one lead to others side effects. The original approach is replaced by a contextual method modifying only the discount field when we need it's needed to don't break code relaying on the fact that the discount field is the total discount to apply to a line. This contextual method ensures that the original value is properly restored on exit and that it will not trigger additional recompute due to the temporary change of the discount value
60172eb to
1396de1
Compare
renda-dev
approved these changes
Sep 27, 2024
Contributor
renda-dev
left a comment
There was a problem hiding this comment.
This solution is really clean and I love it.
Code review, LGTM!
Contributor
|
@IJOL approve please :) |
IJOL
approved these changes
Oct 3, 2024
|
Tested and it recovers funcionality |
mariancuadranetkia
approved these changes
Oct 16, 2024
Member
|
I'm not using the module, but with current review status + coming from a trusted contributor, let's merge it: /ocabot merge patch |
Contributor
|
What a great day to merge this nice PR. Let's do it! |
Contributor
|
Congratulations, your PR was merged at f32db33. Thanks a lot for contributing to OCA. ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When computing the amount total on a sale.order.line, we now avoid to play with the cache since this change introduced in e3e59ba introduces a decline in performance. When the cache in invalidated, fields are flushed to the database and depending computed fields are recomputed..... This ultimately leads to temporary inconsistencies breaking others addons relaying on this one. Moreover, the method used in this original commit 'self.invalidate_cache(fnames=self._discount_fields(), ids=self.ids)' is deprecated and the use of the recommended new one lead to others side effects. The original approach is replaced by a contextual method modifying only the discount field when we need it's needed to don't break code relaying on the fact that the discount field is the total discount to apply to a line. This contextual method ensures that the original value is properly restored on exit and that it will not trigger additional recompute due to the temporary change of the discount value