Skip to content

Commit

Permalink
[IMP] sale_promotion_discount_in_field:refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Volodiay616 committed Aug 24, 2023
1 parent fa9fb19 commit 17169c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def test_program_reward_discount_line_with_applicability(self):
2475.0,
"The order total with programs should be 2475.00",
)
self.assertEqual(result, {})
self.assertEqual(result, {}, msg="Error must not occur")

# Try to use the applied coupon
error_status = program._check_promo_code(self.order, coupon_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ class SaleCouponApplyCode(models.TransientModel):

def apply_coupon(self, order, coupon_code):
# OVERRIDE to apply the program to the order without reward lines
error_status = {}
program_domain = order._get_coupon_program_domain()
program_domain = expression.AND(
[program_domain, [("promo_code", "=", coupon_code)]]
)
additional_conditions = [
("promo_code", "=", coupon_code),
("reward_type", "=", "discount_line"),
("promo_applicability", "!=", "on_next_order"),
]
program_domain = expression.AND([program_domain, additional_conditions])
program = self.env["coupon.program"].search(program_domain)
if (
program
and program.reward_type == "discount_line"
and program.promo_applicability != "on_next_order"
):
if program:
error_status = program._check_promo_code(order, coupon_code)
if not error_status:
order._create_reward_line(program)
Expand Down

0 comments on commit 17169c0

Please sign in to comment.