[IMP]: task related code improve
bzr revid: ksa@tinyerp.co.in-20101122105310-65ms7e4doexy503e
This commit is contained in:
@@ -2422,14 +2422,19 @@ class stock_inventory(osv.osv):
|
||||
return self.pool.get('stock.move').create(cr, uid, move_vals)
|
||||
|
||||
def action_done(self, cr, uid, ids, context=None):
|
||||
""" Finished the inventory
|
||||
@return: True
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
move_obj = self.pool.get('stock.move')
|
||||
for inv in self.browse(cr, uid, ids, context=context):
|
||||
move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context)
|
||||
self.write(cr, uid, [inv.id], {'state':'done'}, context=context)
|
||||
self.write(cr, uid, [inv.id], {'state':'done'}, context=context)
|
||||
return True
|
||||
|
||||
def action_confirm(self, cr, uid, ids, context=None):
|
||||
""" Finishes the inventory and writes its finished date
|
||||
""" Confirm the inventory and writes its finished date
|
||||
@return: True
|
||||
"""
|
||||
if context is None:
|
||||
@@ -2440,7 +2445,7 @@ class stock_inventory(osv.osv):
|
||||
product_context = dict(context, compute_child=False)
|
||||
|
||||
location_obj = self.pool.get('stock.location')
|
||||
for inv in self.browse(cr, uid, ids):
|
||||
for inv in self.browse(cr, uid, ids, context=context):
|
||||
move_ids = []
|
||||
for line in inv.inventory_line_id:
|
||||
pid = line.product_id.id
|
||||
|
||||
@@ -220,12 +220,12 @@ class split_in_production_lot(osv.osv_memory):
|
||||
"""
|
||||
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
|
||||
@@ -254,8 +254,8 @@ class split_in_production_lot(osv.osv_memory):
|
||||
current_move = move_obj.copy(cr, uid, move.id, default_val)
|
||||
new_move.append(current_move)
|
||||
|
||||
if context.get('inventory_id'):
|
||||
inventory_obj.write(cr, uid, context.get('inventory_id'), {'move_ids': [(4, new_move[0])]})
|
||||
if inventory_id:
|
||||
inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, new_move[0])]}, context=context)
|
||||
|
||||
if quantity_rest == 0:
|
||||
current_move = move.id
|
||||
|
||||
@@ -34,6 +34,10 @@ 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')
|
||||
@@ -61,9 +65,9 @@ class stock_split_into(osv.osv_memory):
|
||||
|
||||
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})
|
||||
move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id}, context=context)
|
||||
else:
|
||||
default_val = {
|
||||
'product_qty': quantity_rest,
|
||||
@@ -75,8 +79,8 @@ class stock_split_into(osv.osv_memory):
|
||||
current_move = move_obj.copy(cr, uid, move.id, default_val)
|
||||
new_move.append(current_move)
|
||||
|
||||
if context.get('inventory_id'):
|
||||
inventory_obj.write(cr, uid, context.get('inventory_id'), {'move_ids': [(4, new_move[0])]})
|
||||
if inventory_id:
|
||||
inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, new_move[0])]}, context=context)
|
||||
|
||||
return {}
|
||||
stock_split_into()
|
||||
|
||||
Reference in New Issue
Block a user