From 54e2fa15f86d63bece433daba6015fecb6c48d47 Mon Sep 17 00:00:00 2001 From: nda Date: Wed, 22 Nov 2023 18:57:16 +0000 Subject: [PATCH] [FIX] point_of_sale: retrieve unit price from sale order line Unit price is recomputed on non groupable order line instead of being the same as its sale order line counterpart. Steps to reproduce: - make sure unit measure category are not groupable - create a sale order and add a line with a product with UOM unit (ex: acoustic bloc screens) and quantity 3 - change the default unit price (100$ instead of 295$) - open the point of sale - open the SO and click on settle the order => price is 295$ instead of 100$ on each of the 3 lines opw-3569481 closes odoo/odoo#147487 X-original-commit: 00d8a876c501098da1e8b2f7484e5e3808b61865 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Nicolas Danhier (nda) --- .../sale_order_management_screen.js | 2 +- addons/pos_sale/static/tests/tours/PosSaleTour.js | 2 +- addons/pos_sale/tests/test_pos_sale_flow.py | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js b/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js index 4d33d099f92..fb44f06266d 100644 --- a/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js +++ b/addons/pos_sale/static/src/app/order_management_screen/sale_order_management_screen/sale_order_management_screen.js @@ -259,7 +259,7 @@ export class SaleOrderManagementScreen extends ControlButtonsMixin(Component) { let remaining_quantity = new_line.quantity; while (!floatIsZero(remaining_quantity, 6)) { const splitted_line = new Orderline({ env: this.env }, line_values); - splitted_line.set_quantity(Math.min(remaining_quantity, 1.0)); + splitted_line.set_quantity(Math.min(remaining_quantity, 1.0), true); this.pos.get_order().add_orderline(splitted_line); remaining_quantity -= splitted_line.quantity; } diff --git a/addons/pos_sale/static/tests/tours/PosSaleTour.js b/addons/pos_sale/static/tests/tours/PosSaleTour.js index bb2e0019c19..7c628e16e51 100644 --- a/addons/pos_sale/static/tests/tours/PosSaleTour.js +++ b/addons/pos_sale/static/tests/tours/PosSaleTour.js @@ -146,7 +146,7 @@ registry ProductScreen.confirmOpeningPopup(), ProductScreen.clickQuotationButton(), ProductScreen.selectFirstOrder(), - ProductScreen.totalAmountIs(40.25), + ProductScreen.totalAmountIs(32.2), // 3.5 * 8 * 1.15 ProductScreen.selectedOrderlineHas("Product A", "0.50"), ProductScreen.checkOrderlinesNumber(4), ].flat(), diff --git a/addons/pos_sale/tests/test_pos_sale_flow.py b/addons/pos_sale/tests/test_pos_sale_flow.py index 8a8a09b9349..9136c0dab05 100644 --- a/addons/pos_sale/tests/test_pos_sale_flow.py +++ b/addons/pos_sale/tests/test_pos_sale_flow.py @@ -319,16 +319,17 @@ class TestPoSSale(TestPointOfSaleHttpCommon): 'uom_po_id': uom.id, }) #create a sale order with product_a - self.env['sale.order'].create({ + sale_order = self.env['sale.order'].create({ 'partner_id': self.env.ref('base.res_partner_2').id, 'order_line': [(0, 0, { 'product_id': product_a.id, 'name': product_a.name, 'product_uom_qty': 3.5, 'product_uom': product_a.uom_id.id, - 'price_unit': product_a.lst_price, + 'price_unit': 8, # manually set a different price than the lst_price })], }) + self.assertEqual(sale_order.amount_total, 32.2) # 3.5 * 8 * 1.15 self.main_pos_config.open_ui() self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PosSettleOrderNotGroupable', login="accountman")