Amit (Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-usability-product_filter-apa into
lp:~openerp-dev/openobject-addons/trunk-usability.
Requested reviews:
Raphael Collet (OpenERP) (rco-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-usability-product_filter-apa/+merge/63198
Hello
IMP]:product,stock:
- Added a field 'Stock of Warehouse' and rename 'extended filter' into
'Context'.
- Improved the code for method.
Thanks,
Amit ([email protected])
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-usability-product_filter-apa/+merge/63198
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-usability.
=== modified file 'product/product_view.xml'
--- product/product_view.xml 2011-05-26 08:59:36 +0000
+++ product/product_view.xml 2011-06-02 07:02:24 +0000
@@ -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>
=== modified file 'stock/product.py'
--- stock/product.py 2011-04-08 13:32:12 +0000
+++ stock/product.py 2011-06-02 07:02:24 +0000
@@ -182,6 +182,10 @@
"""
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 @@
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 @@
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 @@
'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." \
=== modified file 'stock/product_view.xml'
--- stock/product_view.xml 2011-03-22 12:48:12 +0000
+++ stock/product_view.xml 2011-06-02 07:02:24 +0000
@@ -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>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp