From e7c92352be575458d2a07db6a71ba5a412921381 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 15 Mar 2019 12:56:17 +0000 Subject: [PATCH] [FIX] stock: picking of move line - Activate Lots and S/N - Track a product A by unique S/N - Receive one unit of A - Sell the unit of A through the POS - Go to Inventory > Products > Lots/Serial Numbers, and open the Upstream Traceability report The line corresponding to the outgoing move line is not linked to the corresponding picking. The field `picking_id` is empty on the `stock.move.line`, so the link is not directly retrieved. Even if the POS should set the `picking_id` field, the traceability report should fallback on the picking of the move. opw-1939413 closes odoo/odoo#31879 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/models/stock_traceability.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/stock/models/stock_traceability.py b/addons/stock/models/stock_traceability.py index 27c42aab30d..0b3c4191724 100644 --- a/addons/stock/models/stock_traceability.py +++ b/addons/stock/models/stock_traceability.py @@ -138,10 +138,11 @@ class MrpStockReport(models.TransientModel): res_model = '' ref = '' res_id = False - if move_line.picking_id: + picking_id = move_line.picking_id or move_line.move_id.picking_id + if picking_id: res_model = 'stock.picking' - res_id = move_line.picking_id.id - ref = move_line.picking_id.name + res_id = picking_id.id + ref = picking_id.name elif move_line.move_id.inventory_id: res_model = 'stock.inventory' res_id = move_line.move_id.inventory_id.id