Merge lp:~openbig/bigconsulting/common_product_field_is_added into lp:bigconsulting

Proposed by Atik Agewan(OpenERP)
Status: Merged
Merged at revision: 35
Proposed branch: lp:~openbig/bigconsulting/common_product_field_is_added
Merge into: lp:bigconsulting
Diff against target: 124 lines (+60/-16)
3 files modified
sales_shop_stock_availability/sales_shop_stock_availability.py (+27/-5)
sales_shop_stock_availability/sales_shop_stock_availability_view.xml (+13/-0)
sales_shop_stock_availability/wizard/stock_shop_availability.py (+20/-11)
To merge this branch: bzr merge lp:~openbig/bigconsulting/common_product_field_is_added
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+28745@code.launchpad.net

Description of the change

Common product field is added...

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'sales_shop_stock_availability/sales_shop_stock_availability.py'
--- sales_shop_stock_availability/sales_shop_stock_availability.py 2010-06-29 06:24:04 +0000
+++ sales_shop_stock_availability/sales_shop_stock_availability.py 2010-06-29 13:03:26 +0000
@@ -26,19 +26,35 @@
26class product_product(osv.osv):26class product_product(osv.osv):
27 _inherit = "product.product"27 _inherit = "product.product"
2828
29 def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}):
30 res = {}
31 product_obj = self.pool.get('product.product')
32 common_ids = product_obj.search(cr,uid,[('common_product','=',True),('id','in',ids)])
33 simple_ids = product_obj.search(cr,uid,[('common_product','=',False),('id','in',ids)])
34 res = super(product_product,self)._product_available(cr, uid, common_ids, field_names, arg, context={})
35 res2 = super(product_product,self)._product_available(cr, uid, simple_ids, field_names, arg, context=context)
36 res.update(res2)
37 return res
38
29 def _product_available_other_shop(self, cr, uid, ids, name, arg, context={}):39 def _product_available_other_shop(self, cr, uid, ids, name, arg, context={}):
30 res = {}40 res = {}
31 product_obj = self.pool.get('product.product')41 product_obj = self.pool.get('product.product')
42 common_id = product_obj.search(cr,uid,[('common_product','=',True),('id','in',ids)])
43 simple_id = product_obj.search(cr,uid,[('common_product','=',False),('id','in',ids)])
32 shop = context.get('shop', False)44 shop = context.get('shop', False)
33 fields_name = ['qty_available','virtual_available']45 fields_name = ['qty_available','virtual_available']
34 stock2 = product_obj._product_available(cr, uid, ids ,fields_name,context={})46 real_res = {}
47 virtual_res = {}
48 if common_id:
49 stock_common = product_obj._product_available(cr, uid, common_id ,fields_name, context={})
50 for key,value in stock_common.items():
51 real_res[key] = stock_common[key]['qty_available']
52 virtual_res[key] = stock_common[key]['virtual_available']
53 stock2 = product_obj._product_available(cr, uid, simple_id ,fields_name,context={})
35 context.update({'shop':shop})54 context.update({'shop':shop})
36 stock1 = product_obj._product_available(cr, uid, ids ,fields_name,context=context)55 stock1 = product_obj._product_available(cr, uid, simple_id ,fields_name,context=context)
37 real_res = {}
38 for key,value in stock2.items():56 for key,value in stock2.items():
39 real_res[key] = stock2[key]['qty_available'] - stock1[key]['qty_available']57 real_res[key] = stock2[key]['qty_available'] - stock1[key]['qty_available']
40 virtual_res = {}
41 for key,value in stock2.items():
42 virtual_res[key] = stock2[key]['virtual_available'] - stock1[key]['virtual_available']58 virtual_res[key] = stock2[key]['virtual_available'] - stock1[key]['virtual_available']
43 for id in ids:59 for id in ids:
44 res[id] = {}60 res[id] = {}
@@ -51,6 +67,12 @@
51 _columns = {67 _columns = {
52 'qty_available_other_shop': fields.function(_product_available_other_shop, method=True, type='float', string='Real Other Stock', help="Current quantities of products in other stock location except selected shop in sale order.", multi='qty_available_other_shop'),68 'qty_available_other_shop': fields.function(_product_available_other_shop, method=True, type='float', string='Real Other Stock', help="Current quantities of products in other stock location except selected shop in sale order.", multi='qty_available_other_shop'),
53 'virtual_qty_available_other_shop': fields.function(_product_available_other_shop, method=True, type='float', string='Virtual Other Stock', help="Current virtual quantities of products in other stock location except selected shop in sale order.", multi='virtual_qty_available_other_shop'),69 'virtual_qty_available_other_shop': fields.function(_product_available_other_shop, method=True, type='float', string='Virtual Other Stock', help="Current virtual quantities of products in other stock location except selected shop in sale order.", multi='virtual_qty_available_other_shop'),
70 'common_product' : fields.boolean('Common Product'),
71 'qty_available': fields.function(_product_available, method=True, type='float', string='Real Stock', help="Current quantities of products in selected locations or all internal if none have been selected.", multi='qty_available'),
72 'virtual_available': fields.function(_product_available, method=True, type='float', string='Virtual Stock', help="Futur stock for this product according to the selected location or all internal if none have been selected. Computed as: Real Stock - Outgoing + Incoming.", multi='qty_available'),
73 'incoming_qty': fields.function(_product_available, method=True, type='float', string='Incoming', help="Quantities of products that are planned to arrive in selected locations or all internal if none have been selected.", multi='qty_available'),
74 'outgoing_qty': fields.function(_product_available, method=True, type='float', string='Outgoing', help="Quantities of products that are planned to leave in selected locations or all internal if none have been selected.", multi='qty_available'),
75
54 }76 }
5577
56product_product()78product_product()
5779
=== modified file 'sales_shop_stock_availability/sales_shop_stock_availability_view.xml'
--- sales_shop_stock_availability/sales_shop_stock_availability_view.xml 2010-06-29 06:24:04 +0000
+++ sales_shop_stock_availability/sales_shop_stock_availability_view.xml 2010-06-29 13:03:26 +0000
@@ -2,6 +2,19 @@
2<openerp>2<openerp>
3 <data>3 <data>
44
5 <record id="product_normal_form_view1" model="ir.ui.view">
6 <field name="name">product.normal.form</field>
7 <field name="model">product.product</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="product.product_normal_form_view"/>
10 <field eval="7" name="priority"/>
11 <field name="arch" type="xml">
12 <field name="variants" position="after">
13 <field name="common_product"/>
14 </field>
15 </field>
16 </record>
17
5 <record id="product_stock_tree_view1" model="ir.ui.view">18 <record id="product_stock_tree_view1" model="ir.ui.view">
6 <field name="name">stock.product.tree</field>19 <field name="name">stock.product.tree</field>
7 <field name="model">product.product</field>20 <field name="model">product.product</field>
821
=== modified file 'sales_shop_stock_availability/wizard/stock_shop_availability.py'
--- sales_shop_stock_availability/wizard/stock_shop_availability.py 2010-06-29 06:24:04 +0000
+++ sales_shop_stock_availability/wizard/stock_shop_availability.py 2010-06-29 13:03:26 +0000
@@ -38,18 +38,27 @@
38 product_id = form['product_id']38 product_id = form['product_id']
39 shop_id = form['shop_id']39 shop_id = form['shop_id']
40 product_obj = self.pool.get('product.product')40 product_obj = self.pool.get('product.product')
41 common_id = product_obj.browse(cr, uid, product_id ,context=context).common_product
41 fields_name = ['qty_available','virtual_available']42 fields_name = ['qty_available','virtual_available']
42 stock2 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={})43 if common_id:
43 context.update({'shop':shop_id,'product_id':product_id})44 stock_common = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={})
44 stock1 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context=context)45 for key,value in stock_common.items():
45 for key,value in stock1.items():46 real_val1 = value['qty_available']
46 real_val1 = value['qty_available']47 virt_val1 = value['virtual_available']
47 virt_val1 = value['virtual_available']48 other_real_val = value['qty_available']
48 for key,value in stock2.items():49 other_virt_val = value['virtual_available']
49 real_val2 = value['qty_available']50 else:
50 virt_val2 = value['virtual_available']51 stock2 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={})
51 other_real_val = real_val2 - real_val152 context.update({'shop':shop_id,'product_id':product_id})
52 other_virt_val = virt_val2 - virt_val153 stock1 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context=context)
54 for key,value in stock1.items():
55 real_val1 = value['qty_available']
56 virt_val1 = value['virtual_available']
57 for key,value in stock2.items():
58 real_val2 = value['qty_available']
59 virt_val2 = value['virtual_available']
60 other_real_val = real_val2 - real_val1
61 other_virt_val = virt_val2 - virt_val1
53 for id in ids:62 for id in ids:
54 self.write(cr, uid, [id],{63 self.write(cr, uid, [id],{
55 'real_stock':real_val1,64 'real_stock':real_val1,

Subscribers

People subscribed via source and target branches