[REF] stock, stock_change_product_qty wizard: removed warehouse field

bzr revid: qdp-launchpad@tinyerp.com-20101221142310-z90hsr4k6tpvx9qz
This commit is contained in:
qdp-launchpad@tinyerp.com
2010-12-21 15:23:10 +01:00
parent 7ff1ae996e
commit 0d6b3dce9f
2 changed files with 5 additions and 24 deletions
@@ -27,22 +27,10 @@ class stock_change_product_qty(osv.osv_memory):
_name = "stock.change.product.qty"
_description = "Change Product Quantity"
_columns = {
'new_quantity': fields.float('Quantity', required=True),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True, ondelete="cascade"),
'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'),
'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade", domain="[('usage', '=', 'internal')]"),
}
def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}):
""" Finds location id for changed warehouse.
@param warehouse_id: Changed id of warehouse.
@return: Dictionary of values.
"""
if warehouse_id:
warehouse = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context)
val = {'location_id': warehouse.lot_stock_id.id}
return {'value': val}
return {}
def default_get(self, cr, uid, fields, context):
""" To get default values for the object.
@param self: The object pointer.
@@ -54,10 +42,6 @@ class stock_change_product_qty(osv.osv_memory):
"""
res = super(stock_change_product_qty, self).default_get(cr, uid, fields, context=context)
wids = self.pool.get('stock.warehouse').search(cr, uid, [], context=context)
if 'warehouse_id' in fields:
res.update({'warehouse_id': wids and wids[0] or False})
if 'new_quantity' in fields:
res.update({'new_quantity': 1})
return res
@@ -84,19 +68,18 @@ class stock_change_product_qty(osv.osv_memory):
res_original = prod_obj_pool.browse(cr, uid, rec_id, context=context)
for data in self.browse(cr, uid, ids, context=context):
invntry_id = inventry_obj.create(cr , uid, {'name': 'INV:' + str(res_original.name)}, context=context)
inventory_id = inventry_obj.create(cr , uid, {'name': _('INV: ') + str(res_original.name)}, context=context)
line_data ={
'inventory_id' : invntry_id,
'inventory_id' : inventory_id,
'product_qty' : data.new_quantity,
'location_id' : data.location_id.id,
'product_id' : rec_id,
'product_uom' : res_original.uom_id.id,
'company_id' : self.pool.get('res.users').browse(cr, uid, uid).company_id.id or False ,
}
line_id = inventry_line_obj.create(cr , uid, line_data, context=context)
inventry_obj.action_confirm(cr, uid, [invntry_id], context=context)
inventry_obj.action_done(cr, uid, [invntry_id], context=context)
inventry_obj.action_confirm(cr, uid, [inventory_id], context=context)
inventry_obj.action_done(cr, uid, [inventory_id], context=context)
return {}
@@ -10,8 +10,6 @@
<separator string="Select Quantity" colspan="4"/>
<newline/>
<field name="new_quantity" />
<newline/>
<field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection"/>
<field name="location_id" />
<separator string="" colspan="4" />
<label string="" colspan="2"/>