-
-
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.
Signed-off-by pedrobaeza
- Loading branch information
Showing
6 changed files
with
82 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from . import wizard |
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
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 @@ | ||
"This module should be renamed sale_coupon_discount_in_field in future migrations for naming consistency." |
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
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 |
25 changes: 25 additions & 0 deletions
25
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,25 @@ | ||
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 | ||
program_domain = order._get_coupon_program_domain() | ||
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: | ||
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 |