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

[16.0][FIX] sale_tier_validation: Basic compatibility with sale_loyalty #3381

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sale_tier_validation/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@

def _get_rejected_notification_subtype(self):
return "sale_tier_validation.sale_order_tier_validation_rejected"

def _get_fields_to_write_validation(self, vals, records_exception_function):
# Don't block order validation when sale_loyalty is installed and no coupon
# is being handled, due to this code assigning always an empty value:
# https://github.com/odoo/odoo/blob/2a7876538e9ea630563e39ee8402b27147d1e428/
# addons/sale_loyalty/models/sale_order.py#L740
# Done here for not creating a glue module as we can detect the situation. The
# only drawback is that this doesn't have any regression test
(

Check warning on line 31 in sale_tier_validation/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_tier_validation/models/sale_order.py#L31

Added line #L31 was not covered by tests
allowed_field_names,
not_allowed_field_names,
) = super()._get_fields_to_write_validation(vals, records_exception_function)
if "applied_coupon_ids" in vals and not vals.get("applied_coupon_ids"):
allowed_field_names += ["applied_coupon_ids"]
return allowed_field_names, not_allowed_field_names

Check warning on line 37 in sale_tier_validation/models/sale_order.py

View check run for this annotation

Codecov / codecov/patch

sale_tier_validation/models/sale_order.py#L36-L37

Added lines #L36 - L37 were not covered by tests
Loading