summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorJeanphy <hzh0292@qq.com>2019-11-16 03:33:03 +0000
committerMartin Trigaux <mat@odoo.com>2020-01-06 13:55:30 +0000
commiteb3257ef21aff01e9b2b745fb5281f6edf0f9234 (patch)
treea3c9fc703aff5973482d9628c755fbb8edb064a0 /addons
parent22f736ca388ac79e168117a1f5a906c199f50a12 (diff)
[FIX] sale_coupon: correct qty for the reward product
Before this commit, a promotion program such as 'Buy 10, get 2 fore free' would have only added a single product in the reward. This commit fixes this problem by ensuring that the quantity for the reward product is computed as the number of times the program is applicable multiplied by the configured reward quantity, instead of just counting the number of times the program is applicable. closes odoo/odoo#42768 X-original-commit: 4251d44c2e635e0a78d2320cf020777ad5c55722 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/sale_coupon/models/sale_order.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/sale_coupon/models/sale_order.py b/addons/sale_coupon/models/sale_order.py
index f6b953cdaef..a9f0bab4edb 100644
--- a/addons/sale_coupon/models/sale_order.py
+++ b/addons/sale_coupon/models/sale_order.py
@@ -83,7 +83,10 @@ class SaleOrder(models.Model):
max_product_qty = sum(order_lines.mapped('product_uom_qty')) or 1
# Remove needed quantity from reward quantity if same reward and rule product
if program._is_valid_product(program.reward_product_id):
- reward_product_qty = max_product_qty // (program.rule_min_quantity + program.reward_product_quantity)
+ # number of times the program should be applied
+ program_in_order = max_product_qty // (program.rule_min_quantity + program.reward_product_quantity)
+ # multipled by the reward qty
+ reward_product_qty = program.reward_product_quantity * program_in_order
else:
reward_product_qty = min(max_product_qty, self.order_line.filtered(lambda x: x.product_id == program.reward_product_id).product_uom_qty)