diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py
index 3ac5ac2632f..b3fa0bfeb99 100644
--- a/addons/procurement/procurement.py
+++ b/addons/procurement/procurement.py
@@ -165,17 +165,13 @@ class procurement_order(osv.osv):
"""
return all(procurement.move_id.state == 'cancel' for procurement in self.browse(cr, uid, ids))
- def check_move_done(self, cr, uid, ids, context={}):
+ def check_move_done(self, cr, uid, ids, context=None):
""" Checks if move is done or not.
@return: True or False.
"""
- res = True
- for proc in self.browse(cr, uid, ids, context):
- if proc.move_id:
- if not proc.move_id.state=='done':
- res = False
- return res
-
+ if not context:
+ context = {}
+ return all(not procurement.move_id or procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids, context=context))
#
# This method may be overrided by objects that override procurement.order
# for computing their own purpose
diff --git a/addons/stock/stock_demo.xml b/addons/stock/stock_demo.xml
index d21f1523226..a3c1989c718 100644
--- a/addons/stock/stock_demo.xml
+++ b/addons/stock/stock_demo.xml
@@ -171,10 +171,15 @@
+
+
+
+
+
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 1de6d59f1ac..c9be557d9a3 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -118,7 +118,7 @@
-
+
@@ -127,17 +127,14 @@
-
-
+
diff --git a/addons/stock/wizard/stock_move.py b/addons/stock/wizard/stock_move.py
index 08df30e7ea8..73158b5d15e 100644
--- a/addons/stock/wizard/stock_move.py
+++ b/addons/stock/wizard/stock_move.py
@@ -218,10 +218,14 @@ class split_in_production_lot(osv.osv_memory):
@param context: A standard dictionary
@return:
"""
+ if context is None:
+ context = {}
+ inventory_id = context.get('inventory_id', False)
prodlot_obj = self.pool.get('stock.production.lot')
+ inventory_obj = self.pool.get('stock.inventory')
move_obj = self.pool.get('stock.move')
new_move = []
- for data in self.browse(cr, uid, ids):
+ for data in self.browse(cr, uid, ids, context=context):
for move in move_obj.browse(cr, uid, move_ids):
move_qty = move.product_qty
quantity_rest = move.product_qty
@@ -249,6 +253,7 @@ class split_in_production_lot(osv.osv_memory):
if quantity_rest > 0:
current_move = move_obj.copy(cr, uid, move.id, default_val)
new_move.append(current_move)
+
if quantity_rest == 0:
current_move = move.id
prodlot_id = False
@@ -259,7 +264,7 @@ class split_in_production_lot(osv.osv_memory):
'name': line.name,
'product_id': move.product_id.id},
context=context)
-
+
move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id, 'state':move.state})
update_val = {}
@@ -268,6 +273,11 @@ class split_in_production_lot(osv.osv_memory):
update_val['product_uos_qty'] = uos_qty_rest
update_val['state'] = move.state
move_obj.write(cr, uid, [move.id], update_val)
+
+ if inventory_id and new_move:
+ for m_id in new_move:
+ inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, m_id)]}, context=context)
+
return new_move
split_in_production_lot()
diff --git a/addons/stock/wizard/stock_splitinto.py b/addons/stock/wizard/stock_splitinto.py
index c514c9714eb..72949695fde 100644
--- a/addons/stock/wizard/stock_splitinto.py
+++ b/addons/stock/wizard/stock_splitinto.py
@@ -34,12 +34,17 @@ class stock_split_into(osv.osv_memory):
}
def split(self, cr, uid, data, context=None):
+ if context is None:
+ context = {}
+
+ inventory_id = context.get('inventory_id', False)
rec_id = context and context.get('active_ids', False)
move_obj = self.pool.get('stock.move')
track_obj = self.pool.get('stock.tracking')
-
+ inventory_obj = self.pool.get('stock.inventory')
quantity = self.browse(cr, uid, data[0], context).quantity or 0.0
for move in move_obj.browse(cr, uid, rec_id):
+ new_move = []
quantity_rest = move.product_qty - quantity
#if move.tracking_id :
# raise osv.except_osv(_('Error!'), _('The current move line is already assigned to a pack, please remove it first if you really want to change it ' \
@@ -56,12 +61,14 @@ class stock_split_into(osv.osv_memory):
'product_uos_qty': quantity,
'product_uos': move.product_uom.id,
})
+
+
if quantity_rest>0:
quantity_rest = move.product_qty - quantity
- tracking_id = track_obj.create(cr, uid, {})
+ tracking_id = track_obj.create(cr, uid, {}, context=context)
if quantity==0.0:
- move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id})
- else:
+ move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id}, context=context)
+ else:
default_val = {
'product_qty': quantity_rest,
'product_uos_qty': quantity_rest,
@@ -69,7 +76,13 @@ class stock_split_into(osv.osv_memory):
'state': move.state,
'product_uos': move.product_uom.id
}
- move_obj.copy(cr, uid, move.id, default_val)
+ current_move = move_obj.copy(cr, uid, move.id, default_val)
+ new_move.append(current_move)
+
+ if inventory_id and new_move:
+ for m_id in new_move:
+ inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, m_id)]}, context=context)
+
return {}
stock_split_into()