[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) <jcb@odoo.com>
Signed-off-by: Nicolas Danhier (nda) <nda@odoo.com>
This commit is contained in:
nda
2023-12-26 17:00:36 +00:00
parent a9ff983d8f
commit 54e2fa15f8
3 changed files with 5 additions and 4 deletions
@@ -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;
}
@@ -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(),
+3 -2
View File
@@ -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")