[FIX] pos_coupon: remove 0€ reward from the list of rewards
Current behavior: When you use a coupon that gives a free product combined with a promo that gives 50% discount. The reward of 50% disappears when you add the free product. Steps to reproduce: - Create 2 program with no conditions : - One that gives 50% discount on all products with a code - One that gives a free product A - Make sure product A has a tax - Open PoS - Add a product with no tax to the order - Apply the 50% discount - Add product A - The reward of 50% disappears Note: This happens because we try to apply a 50% discount on amount that is 0 wich leads to a reward with a NaN amount. Wich makes the reward for the program disappears, because here (https://github.com/odoo/odoo/blob/15.0/addons/pos_coupon/static/src/js/coupon.js#L624) currentMaxKey is null. opw-3529959 closes odoo/odoo#142527 X-original-commit: 9be0955218b5584f27a75b401946a853ac2588ae Signed-off-by: Vlad Stroia (vlst) <vlst@odoo.com> Signed-off-by: Robin Engels (roen) <roen@odoo.com>
This commit is contained in:
@@ -254,3 +254,17 @@ registry.category("web_tour.tours").add("PosLoyaltyTour7", {
|
||||
PosLoyalty.orderTotalIs("90"),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add('PosLoyaltyTour8', {
|
||||
test: true,
|
||||
url: '/pos/web',
|
||||
steps: () =>
|
||||
[
|
||||
ProductScreen.confirmOpeningPopup(),
|
||||
ProductScreen.clickHomeCategory(),
|
||||
|
||||
ProductScreen.clickDisplayedProduct('Product B'),
|
||||
ProductScreen.clickDisplayedProduct('Product A'),
|
||||
ProductScreen.totalAmountIs('50.00'),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
@@ -1259,3 +1259,66 @@ class TestUi(TestPointOfSaleHttpCommon):
|
||||
"PosLoyaltyPromotion",
|
||||
login="pos_user",
|
||||
)
|
||||
|
||||
def test_promo_with_free_product(self):
|
||||
self.env['loyalty.program'].search([]).write({'active': False})
|
||||
self.tax01 = self.env["account.tax"].create({
|
||||
"name": "C01 Tax",
|
||||
"amount": "15.00",
|
||||
})
|
||||
self.product_a = self.env["product.product"].create(
|
||||
{
|
||||
"name": "Product A",
|
||||
"type": "product",
|
||||
"list_price": 100,
|
||||
"available_in_pos": True,
|
||||
"taxes_id": [(6, 0, self.tax01.ids)],
|
||||
}
|
||||
)
|
||||
self.product_b = self.env["product.product"].create(
|
||||
{
|
||||
"name": "Product B",
|
||||
"type": "product",
|
||||
"list_price": 100,
|
||||
"available_in_pos": True,
|
||||
"taxes_id": False,
|
||||
}
|
||||
)
|
||||
self.free_product = self.env['loyalty.program'].create({
|
||||
'name': 'Free Product A',
|
||||
'program_type': 'promotion',
|
||||
'trigger': 'auto',
|
||||
'applies_on': 'current',
|
||||
'rule_ids': [(0, 0, {
|
||||
'reward_point_mode': 'unit',
|
||||
'minimum_qty': 0,
|
||||
})],
|
||||
'reward_ids': [(0, 0, {
|
||||
'reward_type': 'product',
|
||||
'reward_product_id': self.product_a.id,
|
||||
'reward_product_qty': 1,
|
||||
'required_points': 1,
|
||||
})],
|
||||
})
|
||||
self.env['loyalty.program'].create({
|
||||
'name': 'Discount 50%',
|
||||
'program_type': 'promotion',
|
||||
'trigger': 'auto',
|
||||
'applies_on': 'current',
|
||||
'rule_ids': [(0, 0, {
|
||||
'reward_point_mode': 'order',
|
||||
'reward_point_amount': 1,
|
||||
})],
|
||||
'reward_ids': [(0, 0, {
|
||||
'reward_type': 'discount',
|
||||
'required_points': 1,
|
||||
'discount': 50,
|
||||
'discount_mode': 'percent',
|
||||
})],
|
||||
})
|
||||
self.main_pos_config.open_ui()
|
||||
self.start_tour(
|
||||
"/pos/web?config_id=%d" % self.main_pos_config.id,
|
||||
"PosLoyaltyTour8",
|
||||
login="pos_user",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user