diff --git a/sale_invoice_policy/__manifest__.py b/sale_invoice_policy/__manifest__.py index 3bb66a7e568c..654dfbbef0c2 100644 --- a/sale_invoice_policy/__manifest__.py +++ b/sale_invoice_policy/__manifest__.py @@ -16,5 +16,6 @@ "views/res_config_settings_view.xml", "views/sale_view.xml", ], + "installable": False, "post_init_hook": "post_init_hook", } diff --git a/sale_loyalty_exclude/models/sale_order.py b/sale_loyalty_exclude/models/sale_order.py index 21859ff966ee..f45fc47d0c62 100644 --- a/sale_loyalty_exclude/models/sale_order.py +++ b/sale_loyalty_exclude/models/sale_order.py @@ -14,3 +14,22 @@ def _get_no_effect_on_threshold_lines(self): self.ensure_one() lines = self.order_line.filtered(lambda line: line.product_id.loyalty_exclude) return lines | super()._get_no_effect_on_threshold_lines() + + def _has_non_loyalty_exclude(self): + """Check if any order line does not have loyalty_exclude set to True.""" + for line in self.order_line: + if not line.product_id.loyalty_exclude: + return True + return False + + def _get_claimable_rewards(self, forced_coupons=None): + if not self._has_non_loyalty_exclude(): + return {} + else: + return super()._get_claimable_rewards(forced_coupons=forced_coupons) + + def _try_apply_program(self, program, coupon=None): + if not self._has_non_loyalty_exclude(): + return {"error": ("This code is invalid.")} + else: + return super()._try_apply_program(program, coupon=coupon)