Skip to content

[19.0][MIG] sale_loyalty_auto_refresh: Migration to 19.0#354

Open
sergioM-S73 wants to merge 37 commits into
OCA:19.0from
Studio73:19.0-mig-sale_loyalty_auto_refresh
Open

[19.0][MIG] sale_loyalty_auto_refresh: Migration to 19.0#354
sergioM-S73 wants to merge 37 commits into
OCA:19.0from
Studio73:19.0-mig-sale_loyalty_auto_refresh

Conversation

@sergioM-S73

@sergioM-S73 sergioM-S73 commented Jul 13, 2026

Copy link
Copy Markdown

Migration from #347

chienandalu and others added 30 commits July 13, 2026 13:47
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/
oca-ci and others added 6 commits July 13, 2026 13:47
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
@OCA-git-bot OCA-git-bot added series:19.0 mod:sale_loyalty_auto_refresh Module sale_loyalty_auto_refresh labels Jul 13, 2026
@sergioM-S73
sergioM-S73 force-pushed the 19.0-mig-sale_loyalty_auto_refresh branch from deab46f to e4f870b Compare July 13, 2026 11:49
@sergioM-S73
sergioM-S73 force-pushed the 19.0-mig-sale_loyalty_auto_refresh branch from e4f870b to 3ad70b1 Compare July 13, 2026 11:53

@Reyes4711-S73 Reyes4711-S73 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

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.