[19.0][MIG] sale_loyalty_auto_refresh: Migration to 19.0#354
Open
sergioM-S73 wants to merge 37 commits into
Open
[19.0][MIG] sale_loyalty_auto_refresh: Migration to 19.0#354sergioM-S73 wants to merge 37 commits into
sergioM-S73 wants to merge 37 commits into
Conversation
…g for better inheritability
When applying a promo code via wizard, Odoo creates a sale.order.line *before* filling the sale.order 'code_promo_program_id' field. After the creation, though, the auto refresh override kicks in, calling the 'recompute_coupon_lines' method. That method finds a sale.order.line that was created from a promo program, but such program is not linked to the sale.order, and so the line gets deleted. However, since the line has just been created, Odoo will try to run the '_check_company' method on it, which will try to read the field 'company_id' of the deleted line. This operation will result in a MissingError, raised by the '__get__' method of Field class. This error is fixed by adding the 'skip_auto_refresh_coupons' flag to the wizard context when executing the 'process_coupon' method.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: sale-promotion-14.0/sale-promotion-14.0-sale_coupon_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-14-0/sale-promotion-14-0-sale_coupon_auto_refresh/
Currently translated at 100.0% (14 of 14 strings) Translation: sale-promotion-14.0/sale-promotion-14.0-sale_coupon_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-14-0/sale-promotion-14-0-sale_coupon_auto_refresh/zh_CN/
Currently translated at 100.0% (14 of 14 strings) Translation: sale-promotion-14.0/sale-promotion-14.0-sale_coupon_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-14-0/sale-promotion-14-0-sale_coupon_auto_refresh/fr/
we need to pass skip_auto_refresh_coupons=True in the context when adding / editing / removing lines otherwise we can end up with the promotion line being added twice or removed twice (the latter causing a crash)
This commit, alongside with odoo/odoo#77989, fixes MissingError being raised when: - the line(s) that allow coupons to be applied are deleted - the line(s) that allow coupons to be applied are updated making coupons applicable no more Moreover: - a check on which fields are updated is introduced in order to boost performances - the module has been slightly refactored for better readability Closes OCA#20
Currently translated at 6.2% (1 of 16 strings) Translation: sale-promotion-14.0/sale-promotion-14.0-sale_coupon_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-14-0/sale-promotion-14-0-sale_coupon_auto_refresh/it/
This can allow us to work altogether with flexible triggers like the ones we could need with sale_coupon_criteria_order_based TT37479
We should not refresh the lines before the proccess of applying the coupon is finished. TT38806
Use the new `get_depends()` method as the former `depends` attribute (now in `_depends`) is no longer reliable.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: sale-promotion-15.0/sale-promotion-15.0-sale_coupon_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-15-0/sale-promotion-15-0-sale_coupon_auto_refresh/
Currently translated at 100.0% (13 of 13 strings) Translation: sale-promotion-15.0/sale-promotion-15.0-sale_coupon_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-15-0/sale-promotion-15-0-sale_coupon_auto_refresh/es/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: sale-promotion-16.0/sale-promotion-16.0-sale_loyalty_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-16-0/sale-promotion-16-0-sale_loyalty_auto_refresh/
Currently translated at 100.0% (14 of 14 strings) Translation: sale-promotion-16.0/sale-promotion-16.0-sale_loyalty_auto_refresh Translate-URL: https://translation.odoo-community.org/projects/sale-promotion-16-0/sale-promotion-16-0-sale_loyalty_auto_refresh/it/
… inital context Before this change, if so was modifed into the code just after its creation, the auto refresh of the coupon was never done since the new record was returned into a context disabling the auto refresh
sergioM-S73
force-pushed
the
19.0-mig-sale_loyalty_auto_refresh
branch
from
July 13, 2026 11:49
deab46f to
e4f870b
Compare
sergioM-S73
force-pushed
the
19.0-mig-sale_loyalty_auto_refresh
branch
from
July 13, 2026 11:53
e4f870b to
3ad70b1
Compare
BhaveshHeliconia
approved these changes
Jul 15, 2026
Contributor
|
This PR has the |
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.
Migration from #347