diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 1e0fe2d4b75..b4e54f2ec22 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1601,11 +1601,22 @@ class stock_picking(osv.osv): 'stock', self._VIEW_LIST.get(type, 'view_picking_form')) return res and res[1] or False + def _get_picking_for_packing_ui(self, cr, uid, context=None): + return self.search(cr, uid, [('state', '=', 'assigned')], limit=1, context=context)[0] + def action_done_from_packing_ui(self, cr, uid, picking_id, context=None): #fill all the packages with assigned operations - #call action_done of picking + for operation in self.browse(cr, uid, picking_id, context=context).pack_operation_ids: + #pack existing packs + if operation.package_id and operation.result_package_id: + self.pool.get('stock.quant.package').write(cr, uid, operation.package_id.id, {'parent_id': operation.result_package_id.id}, context=context) + if operation.result_package_id: + if operation.package_id: + pass + #don't call action_done of picking because it will make all moves don, but make a partial delivery + #self.action_done(cr, uid, picking_id, context=context) #return id of next picking to work on - pass + return self._get_picking_for_packing_ui(cr, uid, context=context) def action_pack(self, cr, uid, picking_id, context=None): stock_operation_obj = self.pool.get('stock.pack.operation') @@ -1636,6 +1647,8 @@ class stock_picking(osv.osv): product_obj = self.pool.get('product.product') stock_operation_obj = self.pool.get('stock.pack.operation') error_msg = '' + todo_on_moves = [] + todo_on_operations = [] #check if the barcode correspond to a product matching_product_ids = product_obj.search(cr, uid, ['|', ('code', '=', barcode_str), ('ean13', '=', barcode_str)], context=context)