From 4719adbd2117205a6ad1ff2ab381ed09ef31064b Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Mon, 6 Dec 2021 14:29:40 +0000 Subject: [PATCH] [FIX] delivery: sale price for serial products Have a [TEST] product tracked by serial number Create a SO with [TEST], quantity N (at least 2) Add FEDEX int. delivery to the order Validate and confirm delivery On the shipping invoice the product is reported on N lines, one for each serial number, but the price is not splitted accordingly so the total of the invoice will be the original price multiplied by N This commit revert f3488749eed3c4e96f1cc50a2bb2cf87b423c890 not needed anymore after e13f048a78b41d81602e868a3b0c7ded24ce992b opw-2703581 closes odoo/odoo#81130 X-original-commit: 1ad0e4580814bc5ef76f352ed3ed366654ce69bd Signed-off-by: Grazioso Andrea (agr) --- .../tests/test_delivery_stock_move.py | 49 +++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/addons/delivery/tests/test_delivery_stock_move.py b/addons/delivery/tests/test_delivery_stock_move.py index 61e3b381ea4..f3282e98334 100644 --- a/addons/delivery/tests/test_delivery_stock_move.py +++ b/addons/delivery/tests/test_delivery_stock_move.py @@ -40,10 +40,6 @@ class StockMoveInvoice(AccountTestInvoicingCommon): def test_01_delivery_stock_move(self): # Test if the stored fields of stock moves are computed with invoice before delivery flow - self.product_11.write({ - 'weight': 0.25, - }) - self.sale_prepaid = self.SaleOrder.create({ 'partner_id': self.partner_18.id, 'partner_invoice_id': self.partner_18.id, @@ -97,4 +93,49 @@ class StockMoveInvoice(AccountTestInvoicingCommon): self.assertEqual(moves[0].weight, 2.0, 'wrong move weight') # Ship + moves.move_line_ids.write({'qty_done': 2}) self.picking = self.sale_prepaid.picking_ids._action_done() + self.assertEqual(moves[0].move_line_ids.sale_price, 1725.0, 'wrong shipping value') + + def test_02_delivery_stock_move(self): + # Test if SN product shipment line has the correct amount + self.product_cable_management_box.write({ + 'tracking': 'serial' + }) + + serial_numbers = self.env['stock.lot'].create([{ + 'name': str(x), + 'product_id': self.product_cable_management_box.id, + 'company_id': self.env.company.id, + } for x in range(5)]) + + self.sale_prepaid = self.SaleOrder.create({ + 'partner_id': self.partner_18.id, + 'partner_invoice_id': self.partner_18.id, + 'partner_shipping_id': self.partner_18.id, + 'pricelist_id': self.pricelist_id.id, + 'order_line': [(0, 0, { + 'name': 'Cable Management Box', + 'product_id': self.product_cable_management_box.id, + 'product_uom_qty': 2, + 'product_uom': self.product_uom_unit.id, + 'price_unit': 750.00, + })], + }) + + # I add delivery cost in Sales order + delivery_wizard = Form(self.env['choose.delivery.carrier'].with_context({ + 'default_order_id': self.sale_prepaid.id, + 'default_carrier_id': self.normal_delivery.id, + })) + choose_delivery_carrier = delivery_wizard.save() + choose_delivery_carrier.button_confirm() + + # I confirm the SO. + self.sale_prepaid.action_confirm() + moves = self.sale_prepaid.picking_ids.move_ids + # Ship + for ml, lot in zip(moves.move_line_ids, serial_numbers): + ml.write({'qty_done': 1, 'lot_id': lot.id}) + self.picking = self.sale_prepaid.picking_ids._action_done() + self.assertEqual(moves[0].move_line_ids[0].sale_price, 862.5, 'wrong shipping value')