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
1=== modified file 'sales_shop_stock_availability/sales_shop_stock_availability.py'
2--- sales_shop_stock_availability/sales_shop_stock_availability.py 2010-06-29 06:24:04 +0000
3+++ sales_shop_stock_availability/sales_shop_stock_availability.py 2010-06-29 13:03:26 +0000
4@@ -26,19 +26,35 @@
5 class product_product(osv.osv):
6 _inherit = "product.product"
7
8+ def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}):
9+ res = {}
10+ product_obj = self.pool.get('product.product')
11+ common_ids = product_obj.search(cr,uid,[('common_product','=',True),('id','in',ids)])
12+ simple_ids = product_obj.search(cr,uid,[('common_product','=',False),('id','in',ids)])
13+ res = super(product_product,self)._product_available(cr, uid, common_ids, field_names, arg, context={})
14+ res2 = super(product_product,self)._product_available(cr, uid, simple_ids, field_names, arg, context=context)
15+ res.update(res2)
16+ return res
17+
18 def _product_available_other_shop(self, cr, uid, ids, name, arg, context={}):
19 res = {}
20 product_obj = self.pool.get('product.product')
21+ common_id = product_obj.search(cr,uid,[('common_product','=',True),('id','in',ids)])
22+ simple_id = product_obj.search(cr,uid,[('common_product','=',False),('id','in',ids)])
23 shop = context.get('shop', False)
24 fields_name = ['qty_available','virtual_available']
25- stock2 = product_obj._product_available(cr, uid, ids ,fields_name,context={})
26+ real_res = {}
27+ virtual_res = {}
28+ if common_id:
29+ stock_common = product_obj._product_available(cr, uid, common_id ,fields_name, context={})
30+ for key,value in stock_common.items():
31+ real_res[key] = stock_common[key]['qty_available']
32+ virtual_res[key] = stock_common[key]['virtual_available']
33+ stock2 = product_obj._product_available(cr, uid, simple_id ,fields_name,context={})
34 context.update({'shop':shop})
35- stock1 = product_obj._product_available(cr, uid, ids ,fields_name,context=context)
36- real_res = {}
37+ stock1 = product_obj._product_available(cr, uid, simple_id ,fields_name,context=context)
38 for key,value in stock2.items():
39 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']
43 for id in ids:
44 res[id] = {}
45@@ -51,6 +67,12 @@
46 _columns = {
47 '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'),
48 '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'),
49+ 'common_product' : fields.boolean('Common Product'),
50+ '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'),
51+ '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'),
52+ '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'),
53+ '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'),
54+
55 }
56
57 product_product()
58
59=== modified file 'sales_shop_stock_availability/sales_shop_stock_availability_view.xml'
60--- sales_shop_stock_availability/sales_shop_stock_availability_view.xml 2010-06-29 06:24:04 +0000
61+++ sales_shop_stock_availability/sales_shop_stock_availability_view.xml 2010-06-29 13:03:26 +0000
62@@ -2,6 +2,19 @@
63 <openerp>
64 <data>
65
66+ <record id="product_normal_form_view1" model="ir.ui.view">
67+ <field name="name">product.normal.form</field>
68+ <field name="model">product.product</field>
69+ <field name="type">form</field>
70+ <field name="inherit_id" ref="product.product_normal_form_view"/>
71+ <field eval="7" name="priority"/>
72+ <field name="arch" type="xml">
73+ <field name="variants" position="after">
74+ <field name="common_product"/>
75+ </field>
76+ </field>
77+ </record>
78+
79 <record id="product_stock_tree_view1" model="ir.ui.view">
80 <field name="name">stock.product.tree</field>
81 <field name="model">product.product</field>
82
83=== modified file 'sales_shop_stock_availability/wizard/stock_shop_availability.py'
84--- sales_shop_stock_availability/wizard/stock_shop_availability.py 2010-06-29 06:24:04 +0000
85+++ sales_shop_stock_availability/wizard/stock_shop_availability.py 2010-06-29 13:03:26 +0000
86@@ -38,18 +38,27 @@
87 product_id = form['product_id']
88 shop_id = form['shop_id']
89 product_obj = self.pool.get('product.product')
90+ common_id = product_obj.browse(cr, uid, product_id ,context=context).common_product
91 fields_name = ['qty_available','virtual_available']
92- stock2 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={})
93- context.update({'shop':shop_id,'product_id':product_id})
94- stock1 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context=context)
95- for key,value in stock1.items():
96- real_val1 = value['qty_available']
97- virt_val1 = value['virtual_available']
98- for key,value in stock2.items():
99- real_val2 = value['qty_available']
100- virt_val2 = value['virtual_available']
101- other_real_val = real_val2 - real_val1
102- other_virt_val = virt_val2 - virt_val1
103+ if common_id:
104+ stock_common = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={})
105+ for key,value in stock_common.items():
106+ real_val1 = value['qty_available']
107+ virt_val1 = value['virtual_available']
108+ other_real_val = value['qty_available']
109+ other_virt_val = value['virtual_available']
110+ else:
111+ stock2 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={})
112+ context.update({'shop':shop_id,'product_id':product_id})
113+ stock1 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context=context)
114+ for key,value in stock1.items():
115+ real_val1 = value['qty_available']
116+ virt_val1 = value['virtual_available']
117+ for key,value in stock2.items():
118+ real_val2 = value['qty_available']
119+ virt_val2 = value['virtual_available']
120+ other_real_val = real_val2 - real_val1
121+ other_virt_val = virt_val2 - virt_val1
122 for id in ids:
123 self.write(cr, uid, [id],{
124 'real_stock':real_val1,

Subscribers

People subscribed via source and target branches