Skip to content

Commit

Permalink
[FIX] Fixed cod for multi products with attributes and discount wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikul-OSI committed Sep 1, 2023
1 parent 62d9045 commit d7e9e7b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sale_loyalty_discount_attribute/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ def _get_reward_values_discount(self, reward, coupon, **kwargs):
reward.limit_discounted_attributes
and reward.limit_discounted_attributes != "disabled"
):
for so_lines in self.order_line.filtered(lambda l: not l.reward_id):
attributes_wise_price_unit = 0.0
for so_lines in self.order_line.filtered(
lambda l: not l.reward_id
and l.product_id.id in reward.discount_product_ids.ids
):
for value_line in so_lines.product_no_variant_attribute_value_ids:
test_unit = price_unit
test_unit += value_line.price_extra * discount_value
if value_line.attribute_id not in reward_attributes:
price_unit += value_line.price_extra * discount_value
attributes_wise_price_unit += (
value_line.price_extra * discount_value
)
# if limit discounted attributes is set to attributes,
# sales list price should not be considered for discount as well
# and is counted as many times as the product repeats itself in the lines
Expand All @@ -41,6 +45,7 @@ def _get_reward_values_discount(self, reward, coupon, **kwargs):
* len(so_lines)
* discount_value
)
price_unit = abs(price_unit) - attributes_wise_price_unit
discount.update({"price_unit": price_unit})
# replaces the discount line
res[i] = discount
Expand Down

0 comments on commit d7e9e7b

Please sign in to comment.