[IMP]: task-1773 improve for production lot and pack

bzr revid: ksa@tinyerp.co.in-20101119142159-rxiuk694diyq763t
This commit is contained in:
ksa (Open ERP) 2010-11-19 19:51:59 +05:30
parent 2279e51617
commit e542c34a12
3 changed files with 24 additions and 6 deletions

View File

@ -118,7 +118,7 @@
</form>
</field>
</page><page string="Posted Inventory" groups="base.group_extended">
<field colspan="2" name="move_ids" nolabel="1" widget="one2many_list">
<field colspan="2" name="move_ids" nolabel="1" widget="one2many_list" context="{'inventory_id':active_id}" >
<tree string="Stock Moves">
<field name="product_id"/>
<field name="product_qty" on_change="onchange_quantity(product_id, product_qty, product_uom, product_uos)"/>
@ -127,17 +127,19 @@
<button name="%(track_line)d" string="Split in production lots" type="action"
icon="terp-stock_effects-object-colorize"
attrs="{'invisible': [('prodlot_id','&lt;&gt;',False)]}"
context="{'default_use_exist': picking_id.type=='in'}"
states="draft,done,cancel"
context="{'inventory_id':parent.id}"
groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="setlast_tracking" string="Put in current pack" type="object"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
context="{'inventory_id':parent.id}"
states="draft,done,cancel"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
context="{'inventory_id':parent.id}"
states="draft,done,cancel"/>
<field name="location_id"/>
<field name="location_dest_id"/>

View File

@ -218,7 +218,11 @@ class split_in_production_lot(osv.osv_memory):
@param context: A standard dictionary
@return:
"""
if context is None:
context = {}
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):
@ -249,6 +253,10 @@ 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 context:
self.pool.get('stock.inventory').write(cr, uid, context.get('inventory_id'), {'move_ids': [(4, new_move[0])]})
if quantity_rest == 0:
current_move = move.id
prodlot_id = False
@ -259,7 +267,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 +276,7 @@ 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)
return new_move
split_in_production_lot()

View File

@ -37,9 +37,9 @@ class stock_split_into(osv.osv_memory):
rec_id = context and context.get('active_ids', False)
move_obj = self.pool.get('stock.move')
track_obj = self.pool.get('stock.tracking')
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 +56,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, {})
if quantity==0.0:
move_obj.write(cr, uid, [move.id], {'tracking_id': tracking_id})
else:
else:
default_val = {
'product_qty': quantity_rest,
'product_uos_qty': quantity_rest,
@ -69,7 +71,12 @@ 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 context:
self.pool.get('stock.inventory').write(cr, uid, context.get('inventory_id'), {'move_ids': [(4, new_move[0])]})
return {}
stock_split_into()