[IMP] add field 'Warehouse' next to 'Location' in product search view

bzr revid: rco@openerp.com-20110708085203-4o5ubfe2xn7ml76b
This commit is contained in:
Raphael Collet 2011-07-08 10:52:03 +02:00
commit 794ff1fdf3
3 changed files with 13 additions and 7 deletions

View File

@ -19,7 +19,7 @@
<field name="name"/>
<field name="categ_id" widget="selection" operator="child_of" groups="base.group_extended"/>
<newline/>
<group expand="0" string="Extended Filters..." groups="base.group_extended">
<group expand="0" string="Context..." groups="base.group_extended">
<field name="pricelist_id" widget="selection" context="{'pricelist': self}" />
</group>
<newline/>

View File

@ -182,6 +182,10 @@ class product_product(osv.osv):
"""
if context is None:
context = {}
location_obj = self.pool.get('stock.location')
warehouse_obj = self.pool.get('stock.warehouse')
states = context.get('states',[])
what = context.get('what',())
if not ids:
@ -207,18 +211,18 @@ class product_product(osv.osv):
if type(context['location']) == type(1):
location_ids = [context['location']]
elif type(context['location']) in (type(''), type(u'')):
location_ids = self.pool.get('stock.location').search(cr, uid, [('name','ilike',context['location'])], context=context)
location_ids = location_obj.search(cr, uid, [('name','ilike',context['location'])], context=context)
else:
location_ids = context['location']
else:
location_ids = []
wids = self.pool.get('stock.warehouse').search(cr, uid, [], context=context)
for w in self.pool.get('stock.warehouse').browse(cr, uid, wids, context=context):
wids = warehouse_obj.search(cr, uid, [], context=context)
for w in warehouse_obj.browse(cr, uid, wids, context=context):
location_ids.append(w.lot_stock_id.id)
# build the list of ids of children of the location given by id
if context.get('compute_child',True):
child_location_ids = self.pool.get('stock.location').search(cr, uid, [('location_id', 'child_of', location_ids)])
child_location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', location_ids)])
location_ids = child_location_ids or location_ids
else:
location_ids = location_ids
@ -333,7 +337,8 @@ class product_product(osv.osv):
'track_production': fields.boolean('Track Manufacturing Lots' , help="Forces to specify a Production Lot for all moves containing this product and generated by a Manufacturing Order"),
'track_incoming': fields.boolean('Track Incoming Lots', help="Forces to specify a Production Lot for all moves containing this product and coming from a Supplier Location"),
'track_outgoing': fields.boolean('Track Outgoing Lots', help="Forces to specify a Production Lot for all moves containing this product and going to a Customer Location"),
'location_id': fields.dummy(string='Stock Location', relation='stock.location', type='many2one'),
'location_id': fields.dummy(string='Location', relation='stock.location', type='many2one'),
'warehouse_id': fields.dummy(string='Warehouse', relation='stock.warehouse', type='many2one'),
'valuation':fields.selection([('manual_periodic', 'Periodical (manual)'),
('real_time','Real Time (automated)'),], 'Inventory Valuation',
help="If real-time valuation is enabled for a product, the system will automatically write journal entries corresponding to stock moves." \

View File

@ -9,7 +9,8 @@
<field name="inherit_id" ref="product.product_search_form_view"/>
<field name="arch" type="xml">
<field name="pricelist_id" position="before">
<field name="location_id" context="{'location': self}"/>
<field name="location_id" widget="selection" context="{'location': self}"/>
<field name="warehouse_id" widget="selection" context="{'warehouse': self}"/>
<separator orientation="vertical"/>
</field>
</field>