[IMP] procurement: restrict location fields in minimum stock rules to group_locations, and provide default values for them

bzr revid: rco@openerp.com-20120514144041-jawwyhn27gski0dk
This commit is contained in:
Raphael Collet
2012-05-14 16:40:41 +02:00
parent eab2bb4140
commit 5b9ef6ba23
2 changed files with 14 additions and 3 deletions
+11
View File
@@ -536,6 +536,17 @@ class stock_warehouse_orderpoint(osv.osv):
('qty_multiple_check', 'CHECK( qty_multiple > 0 )', 'Qty Multiple must be greater than zero.'),
]
def default_get(self, cr, uid, fields, context=None):
res = super(stock_warehouse_orderpoint, self).default_get(cr, uid, fields, context)
# default 'warehouse_id' and 'location_id'
if 'warehouse_id' not in res:
warehouse = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'warehouse0', context)
res['warehouse_id'] = warehouse.id
if 'location_id' not in res:
warehouse = self.pool.get('stock.warehouse').browse(cr, uid, res['warehouse_id'], context)
res['location_id'] = warehouse.lot_stock_id.id
return res
def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context=None):
""" Finds location id for changed warehouse.
@param warehouse_id: Changed id of warehouse.
+3 -3
View File
@@ -283,12 +283,12 @@
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<group name="misc" position="after">
<group col="2" colspan="2" attrs="{'invisible':[('type', '=', 'service')]}">
<group col="2" colspan="2" attrs="{'invisible':[('type', '=', 'service')]}" groups="stock.group_stock_manager">
<separator string="Minimum Stock Rules" colspan="2"/>
<field name="orderpoint_ids" context="{'default_product_uom': uom_id}" nolabel="1">
<tree string="Minimum Stock Rule" editable="bottom">
<field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection"/>
<field name="location_id"/>
<field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection" groups="stock.group_locations"/>
<field name="location_id" groups="stock.group_locations"/>
<field name="product_min_qty"/>
<field name="product_max_qty"/>
<field name="product_uom" groups="product.group_uom"/>