[IMP]:product,stock:Added a field 'Stock of Warehouse' and rename 'extended filter' into 'Context' and also improved the code for method.
bzr revid: apa@tinyerp.com-20110602065559-20u83owfgt32sb1o
This commit is contained in:
parent
baed775786
commit
071ae27134
|
@ -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/>
|
||||
|
@ -201,8 +201,8 @@
|
|||
<field name="res_model">product.product</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="context">{"search_default_filter_to_sell":1}</field>
|
||||
<field name="view_id" ref="product_product_tree_view"/>
|
||||
<field name="search_view_id" ref="product_search_form_view"/>
|
||||
<field name="view_id" ref="product_product_tree_view"/>
|
||||
<field name="search_view_id" ref="product_search_form_view"/>
|
||||
<field name="help">You must define a Product for everything you buy or sell. Products can be raw materials, stockable products, consumables or services. The Product form contains detailed information about your products related to procurement logistics, sales price, product category, suppliers and so on.</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
@ -198,6 +202,15 @@ class product_product(osv.osv):
|
|||
context['warehouse'] = res2[0]
|
||||
|
||||
if context.get('warehouse', False):
|
||||
|
||||
# write code for added filter in product view.
|
||||
if isinstance(context['warehouse'],str):
|
||||
warehouse_id = warehouse_obj.search(cr, uid, [('name','ilike',context['warehouse'])], context=context)
|
||||
if warehouse_id:
|
||||
context['warehouse'] = warehouse_id[0]
|
||||
else:
|
||||
raise osv.except_osv(_('Warning!'),_('There is no warehouse defined name like: "%s"')%(context['warehouse'],))
|
||||
|
||||
cr.execute('select lot_stock_id from stock_warehouse where id=%s', (int(context['warehouse']),))
|
||||
res2 = cr.fetchone()
|
||||
if res2:
|
||||
|
@ -207,18 +220,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
|
||||
|
@ -334,6 +347,7 @@ class product_product(osv.osv):
|
|||
'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'),
|
||||
'warehouse_id': fields.dummy(string='Stock of 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." \
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<field name="pricelist_id" position="before">
|
||||
<field name="location_id" context="{'location': self}"/>
|
||||
<field name="warehouse_id" context="{'warehouse': self}"/>
|
||||
<separator orientation="vertical"/>
|
||||
</field>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue