Skip to content

Commit

Permalink
[FIX] sale_promotion_discount_in_field: apply code
Browse files Browse the repository at this point in the history
when Promo code used, promotion was not added to Applied Promo Program
of current order.
  • Loading branch information
Volodiay616 authored and solo4games committed Aug 28, 2023
1 parent 0c52630 commit 89f8a62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions sale_promotion_discount_in_field/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_coupon_apply_code
27 changes: 27 additions & 0 deletions sale_promotion_discount_in_field/wizard/sale_coupon_apply_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from odoo import models
from odoo.osv import expression


class SaleCouponApplyCode(models.TransientModel):
_inherit = "sale.coupon.apply.code"

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)]]
)
program = self.env["coupon.program"].search(program_domain)
if (
program
and program.reward_type == "discount_line"
and program.promo_applicability != "on_next_order"
):
error_status = program._check_promo_code(order, coupon_code)
if not error_status:
order._create_reward_line(program)
order.code_promo_program_id = program
else:
return super().apply_coupon(order, coupon_code)
return error_status

0 comments on commit 89f8a62

Please sign in to comment.