[FIX] sale_loyalty: open wizard to select reward defined by tag

Currently, when there is only one loyalty program available for an
order, we apply it automatically without opening the wizard. This is a
problem when the reward is a free product among all with a specific tags
because the user can not choose it (it takes the first one by default)

We now automatically apply only when there is only one reward possible

opw-3774944

closes odoo/odoo#161442

Signed-off-by: Morgane Demesmaeker <edm@odoo.com>
This commit is contained in:
Demesmaeker
2024-04-11 13:17:02 +00:00
parent 54f30f8869
commit 985c16cf6b
+2 -1
View File
@@ -101,7 +101,8 @@ class SaleOrder(models.Model):
claimable_rewards = self._get_claimable_rewards()
if len(claimable_rewards) == 1:
coupon = next(iter(claimable_rewards))
if len(claimable_rewards[coupon]) == 1:
rewards = claimable_rewards[coupon]
if len(rewards) == 1 and not rewards.multi_product:
self._apply_program_reward(claimable_rewards[coupon], coupon)
return True
elif not claimable_rewards: