-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] pos_loyalty,pos_sale_loyalty: avoid creating 2 loyalty cards
Current behavior: When you create an order for partner A but do not confirm it, then settle the order in the PoS and add some product. You will have 2 loyalty cards created for partner A. This is happening because when you confirm the order in the PoS it will confirm the sale order and create a first loyalty card, but the PoS will not be aware of this and when it will try to apply the point for the product added through the PoS it will create a new loyalty card. Steps to reproduce: - Activate a loyalty program - Create a partner A - Create a sale order for partner A but do not confirm it - Go to the PoS and settle the order - Add some product to the order - Pay the order - Go to the backend and check the loyalty cards for partner A - You will have 2 loyalty cards created To avoid this we will check if the partner has a loyalty card before creating a new one. opw-3582174 closes odoo#149621 X-original-commit: ecd62dc Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com> Signed-off-by: Robin Engels (roen) <roen@odoo.com>
- Loading branch information
1 parent
4d997bc
commit e1ed785
Showing
5 changed files
with
98 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
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
25 changes: 25 additions & 0 deletions
25
addons/pos_sale_loyalty/static/tests/tours/PosSaleLoyaltyTour.js
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 @@ | ||
/** @odoo-module **/ | ||
|
||
import * as PaymentScreen from "@point_of_sale/../tests/tours/helpers/PaymentScreenTourMethods"; | ||
import * as ReceiptScreen from "@point_of_sale/../tests/tours/helpers/ReceiptScreenTourMethods"; | ||
import * as ProductScreenPos from "@point_of_sale/../tests/tours/helpers/ProductScreenTourMethods"; | ||
import * as ProductScreenSale from "@pos_sale/../tests/helpers/ProductScreenTourMethods"; | ||
const ProductScreen = { ...ProductScreenPos, ...ProductScreenSale }; | ||
import { registry } from "@web/core/registry"; | ||
|
||
registry | ||
.category("web_tour.tours") | ||
.add('PosSaleLoyaltyTour1', { | ||
test: true, | ||
url: '/pos/ui', | ||
steps: () => [ | ||
ProductScreen.confirmOpeningPopup(), | ||
ProductScreen.clickQuotationButton(), | ||
ProductScreen.selectFirstOrder(), | ||
ProductScreen.clickDisplayedProduct('Desk Pad'), | ||
ProductScreen.clickPayButton(), | ||
PaymentScreen.clickPaymentMethod('Bank'), | ||
PaymentScreen.clickValidate(), | ||
ReceiptScreen.isShown(), | ||
].flat(), | ||
}); |
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,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import test_pos_sale_loyalty |
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,45 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon | ||
from odoo.tests import tagged | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestPoSSaleLoyalty(TestPointOfSaleHttpCommon): | ||
def test_pos_sale_loyalty_1(self): | ||
"""Test that only one loyalty card is created when settling an unconfirmed order.""" | ||
self.env['loyalty.program'].search([]).write({'active': False}) | ||
self.env['loyalty.program'].create({ | ||
'name': 'Test Loyalty Program', | ||
'program_type': 'loyalty', | ||
'trigger': 'auto', | ||
'applies_on': 'both', | ||
'rule_ids': [ | ||
(0, 0, { | ||
'reward_point_mode': 'money', | ||
'minimum_amount': 1, | ||
'reward_point_amount': 1, | ||
}), | ||
], | ||
'reward_ids': [ | ||
(0, 0, { | ||
'reward_type': 'discount', | ||
'discount': 1, | ||
'required_points': 1000, | ||
'discount_mode': 'percent', | ||
'discount_applicability': 'order', | ||
}), | ||
], | ||
}) | ||
self.env['sale.order'].create({ | ||
'partner_id': self.partner_a.id, | ||
'order_line': [(0, 0, { | ||
'product_id': self.desk_organizer.id, | ||
'product_uom_qty': 1, | ||
'price_unit': 100, | ||
})] | ||
}) | ||
|
||
self.main_pos_config.open_ui() | ||
self.start_tour("/pos/web?config_id=%d" % self.main_pos_config.id, "PosSaleLoyaltyTour1", login="accountman") | ||
self.assertEqual(self.env['loyalty.card'].search_count([('partner_id', '=', self.partner_a.id)]), 1) |