From 9f7c476a6f6ec1ef5eed2cd44f165f5201747ab5 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 23 May 2019 10:57:23 +0000 Subject: [PATCH] [FIX] stock: missing picking type - Activate 'Lots & Serial Numbers' - Create a stockable product A, enable tracking 'By Lots' - From the menu Inventory > Operations > Transfers, create a picking: Set a picking type One line of A It is not possible to set the lot number to validate the transfer. When creating a picking from the menu, the context key `default_picking_type_id` is not set. Therefore, the field `picking_type_id` is empty on the `stock.move`. We can fall back on the `picking_type_id` of the picking. opw-1981958 closes odoo/odoo#33611 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/models/stock_move.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 25cc6163c9c..2e14e1c1360 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -464,6 +464,7 @@ class StockMove(models.Model): else: view = self.env.ref('stock.view_stock_move_nosuggest_operations') + picking_type_id = self.picking_type_id or self.picking_id.picking_type_id return { 'name': _('Detailed Operations'), 'type': 'ir.actions.act_window', @@ -476,8 +477,8 @@ class StockMove(models.Model): 'res_id': self.id, 'context': dict( self.env.context, - show_lots_m2o=self.has_tracking != 'none' and (self.picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id), # able to create lots, whatever the value of ` use_create_lots`. - show_lots_text=self.has_tracking != 'none' and self.picking_type_id.use_create_lots and not self.picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id, + show_lots_m2o=self.has_tracking != 'none' and (picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id), # able to create lots, whatever the value of ` use_create_lots`. + show_lots_text=self.has_tracking != 'none' and picking_type_id.use_create_lots and not picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id, show_source_location=self.location_id.child_ids, show_destination_location=self.location_dest_id.child_ids, show_package=not self.location_id.usage == 'supplier',