From f438a11099dc0410fed3305d9fb0aa0707bde10c Mon Sep 17 00:00:00 2001 From: amoyaux Date: Tue, 8 Aug 2017 16:31:53 +0200 Subject: [PATCH] [FIX] stock : return serial number When an operation has the check for create new lots/serial numbers activated and it exists a return that use this operation. The return with serial number is not possible since it will display the view for creating new serial number while we are returning some of them. Trying to add the serial number name will fail due to the constraint that ensure maximum one specific serial number by product. This commit change the context before calling the view in order to always display the many2one lot_id if the move is a return. --- addons/stock/models/stock_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index cb4012ae219..c719f9700af 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -431,8 +431,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'), # 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', + 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_source_location=self.location_id.child_ids, show_destination_location=self.location_dest_id.child_ids, show_package=not self.location_id.usage == 'supplier',