From d448db602a0a1fa2234b1e13b85db5b3514bfa09 Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Fri, 23 Apr 2021 09:40:58 +0000 Subject: [PATCH] [FIX] point_of_sale: use lot's location for SML's location source When selling a tracked product that comes from a specific place in the warehouse, the module will ignore this information and set the parent warehouse as source location. To reproduce the error: (Use demo data) 1. In Settings, enable "Multi-Warehouses" 2. Create a product P: - Product Type: Storable Product - Available in Pos: True - Tracking: By Unique Serial Number 3. Update its quantity: - Location: WH/Stock/Shelf 1 - Serial Number: USN01 - Qty: 1 4. Start a POS session 5. Sell P - Enter the same serial number 6. Go back to quantity update page for product P Error: The quantity for "WH/Stock/Shelf 1, USN01" is still 1, it should be 0. Moreover, a new line appeared: "WH/Stock, USN01, -1" which is incorrect. The POS module considered that the product sold came from WH/Stock instead of WH/Stock/Shelf 1. OPW-2473002 closes odoo/odoo#70194 X-original-commit: 02a68278a9af2c477cc9a30716feabb0b533b7e7 Signed-off-by: pimodoo Signed-off-by: Adrien Widart --- addons/point_of_sale/models/stock_picking.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/point_of_sale/models/stock_picking.py b/addons/point_of_sale/models/stock_picking.py index 2e496888931..e6cbc095e0c 100644 --- a/addons/point_of_sale/models/stock_picking.py +++ b/addons/point_of_sale/models/stock_picking.py @@ -117,8 +117,10 @@ class StockPicking(models.Model): 'product_id': line.product_id.id, 'name': lot.lot_name, }) + quant = existing_lot.quant_ids.filtered(lambda q: q.quantity > 0.0 or q.location_id.parent_path.startswith(move.location_id.parent_path))[-1:] ml_vals.update({ 'lot_id': existing_lot.id, + 'location_id': quant.location_id.id or move.location_id.id }) else: ml_vals.update({