diff --git a/sale_tier_validation/models/sale_order.py b/sale_tier_validation/models/sale_order.py index 3c7eecf070f..0a0f7bbe5d8 100644 --- a/sale_tier_validation/models/sale_order.py +++ b/sale_tier_validation/models/sale_order.py @@ -20,3 +20,18 @@ def _get_accepted_notification_subtype(self): 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 + ( + 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