diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 9bc40a1e691..e0ab1101535 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2229,6 +2229,7 @@ class stock_inventory(osv.osv): # price = line.product_id.standard_price or 0.0 amount = self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id})[pid] + #TOCHECK: Why put restriction like new inventory qty should greater available qty ? change = line.product_qty - amount lot_id = line.prod_lot_id.id if change: diff --git a/addons/stock/wizard/stock_inventory_line_split.py b/addons/stock/wizard/stock_inventory_line_split.py index b07d27c7656..5c4e8f708d2 100644 --- a/addons/stock/wizard/stock_inventory_line_split.py +++ b/addons/stock/wizard/stock_inventory_line_split.py @@ -47,7 +47,11 @@ class stock_inventory_line_split(osv.osv_memory): res = {} line = self.pool.get('stock.inventory.line').browse(cr, uid, record_id) if 'product_id' in fields: - res.update({'product_id':line.product_id.id}) + res.update({'product_id':line.product_id.id}) + if 'product_uom' in fields: + res.update({'product_uom': line.product_uom.id}) + if 'qty' in fields: + res.update({'qty': line.product_qty}) return res def split(self, cr, uid, ids, line_ids, context=None): @@ -68,11 +72,13 @@ class stock_inventory_line_split(osv.osv_memory): for inv_line in line_obj.browse(cr, uid, line_ids): line_qty = inv_line.product_qty quantity_rest = inv_line.product_qty - new_line = [] - for line in data.line_ids: + new_line = [] + if data.use_exist: + lines = [l for l in data.line_exist_ids if l] + else: + lines = [l for l in data.line_ids if l] + for line in lines: quantity = line.quantity - - if quantity <= 0 or line_qty == 0: continue quantity_rest -= quantity @@ -85,14 +91,13 @@ class stock_inventory_line_split(osv.osv_memory): current_line = line_obj.copy(cr, uid, inv_line.id, default_val) new_line.append(current_line) prodlot_id = False - if line.use_exist and line.name: - prodlot_id = prodlot_obj.search(cr, uid, [('prefix','=',line.name),('product_id','=',data.product_id.id)]) - if prodlot_id: - prodlot_id = prodlot_id[0] + if data.use_exist: + prodlot_id = line.prodlot_id.id if not prodlot_id: - sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') - prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix' : line.name}, - {'product_id': data.product_id.id}) + prodlot_id = prodlot_obj.create(cr, uid, { + 'name': line.name, + 'product_id': inv_line.product_id.id}, + context=context) line_obj.write(cr, uid, [current_line], {'prod_lot_id': prodlot_id}) prodlot = prodlot_obj.browse(cr, uid, prodlot_id) diff --git a/addons/stock/wizard/stock_inventory_line_split_view.xml b/addons/stock/wizard/stock_inventory_line_split_view.xml index 42b8a4648da..fc188184c42 100644 --- a/addons/stock/wizard/stock_inventory_line_split_view.xml +++ b/addons/stock/wizard/stock_inventory_line_split_view.xml @@ -1,38 +1,61 @@ - - - Split inventory lines - stock.inventory.line.split - form - -
- - - - - - - - - - - - - - - -