mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 22:32:03 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,9 +1,11 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import Command
|
||||
from datetime import timedelta
|
||||
|
||||
from odoo.fields import Command, Date
|
||||
from odoo.tests.common import tagged
|
||||
|
||||
from odoo.addons.sale_loyalty.tests.common import TestSaleCouponCommon
|
||||
from odoo.tests.common import tagged
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
|
|
@ -36,13 +38,11 @@ class TestUnlinkReward(TestSaleCouponCommon):
|
|||
Command.create({
|
||||
'product_id': self.product_A.id,
|
||||
'name': 'Ordinary Product A',
|
||||
'product_uom': self.uom_unit.id,
|
||||
'product_uom_qty': 1.0,
|
||||
}),
|
||||
Command.create({
|
||||
'product_id': self.product_B.id,
|
||||
'name': '2 Product B',
|
||||
'product_uom': self.uom_unit.id,
|
||||
'product_uom_qty': 1.0,
|
||||
}),
|
||||
]})
|
||||
|
|
@ -53,3 +53,19 @@ class TestUnlinkReward(TestSaleCouponCommon):
|
|||
# Check that the reward is archived and not deleted
|
||||
self.assertTrue(self.reward.exists())
|
||||
self.assertFalse(self.reward.active)
|
||||
|
||||
def test_unlink_expired_coupon_line(self):
|
||||
"""Ensure that lines linked to expired coupons get unlinked from the order."""
|
||||
order = self.empty_order
|
||||
order.order_line = [Command.create({'product_id': self.product_A.id})]
|
||||
coupon_program = self.code_promotion_program
|
||||
self.env['loyalty.generate.wizard'].with_context(active_id=coupon_program.id).create({
|
||||
'coupon_qty': 1,
|
||||
'points_granted': 1,
|
||||
}).generate_coupons()
|
||||
coupon = coupon_program.coupon_ids
|
||||
self._apply_promo_code(order, coupon.code)
|
||||
self.assertTrue(order.order_line.coupon_id)
|
||||
coupon.expiration_date = Date.today() - timedelta(days=1)
|
||||
order._update_programs_and_rewards()
|
||||
self.assertFalse(order.order_line.coupon_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue