-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] sale_promotion_discount_in_field: apply code
when Promo code used, promotion was not added to Applied Promo Program of current order.
- Loading branch information
1 parent
0c52630
commit 89f8a62
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
sale_promotion_discount_in_field/wizard/sale_coupon_apply_code.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |