Merge lp:~openbig/bigconsulting/product_price_information_patch into lp:bigconsulting
- product_price_information_patch
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 51 |
Proposed branch: | lp:~openbig/bigconsulting/product_price_information_patch |
Merge into: | lp:bigconsulting |
Diff against target: |
544 lines (+155/-227) 5 files modified
product_price_information/product_price_info.py (+61/-108) product_price_information/wizard/sale_prize_information.py (+43/-64) product_price_information/wizard/sale_prize_information_view.xml (+25/-28) sales_shop_stock_availability/sales_shop_stock_availability.py (+7/-6) sales_shop_stock_availability/wizard/stock_shop_availability.py (+19/-21) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/product_price_information_patch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+30288@code.launchpad.net |
Commit message
Description of the change
Apply the changes of patch on the sales_shop_
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 'product_price_information/product_price_info.py' |
2 | --- product_price_information/product_price_info.py 2010-06-29 06:24:04 +0000 |
3 | +++ product_price_information/product_price_info.py 2010-07-19 15:15:54 +0000 |
4 | @@ -20,7 +20,6 @@ |
5 | # |
6 | ############################################################################## |
7 | from osv import fields, osv |
8 | -from tools import config |
9 | |
10 | class sale_order_line(osv.osv): |
11 | _inherit = "sale.order.line" |
12 | @@ -28,11 +27,13 @@ |
13 | 'sale_price_unit_tax': fields.float('Sale price W/O taxes'), |
14 | } |
15 | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, |
16 | - uom=False, qty_uos=0, uos=False, name='', partner_id=False, |
17 | - lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): |
18 | - tax_obj = self.pool.get('account.tax') |
19 | + uom=False, qty_uos=0, uos=False, name='', partner_id=False, |
20 | + lang=False, update_tax=True, date_order=False, packaging=False, |
21 | + fiscal_position=False, flag=False): |
22 | + |
23 | result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, |
24 | - uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging, fiscal_position, flag) |
25 | + uom, qty_uos, uos, name, partner_id, lang, |
26 | + update_tax, date_order, packaging, fiscal_position, flag) |
27 | if product: |
28 | context = {'lang': lang, 'partner_id': partner_id, 'qty': qty} |
29 | product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context) |
30 | @@ -82,24 +83,25 @@ |
31 | } |
32 | |
33 | def set_default(self, cr, uid, ids, context=None): |
34 | - for o in self.browse(cr, uid, ids, context=context): |
35 | - ir_values_obj = self.pool.get('ir.values') |
36 | - ir_values_obj.set(cr, uid, 'default', False, 'price_type', ['sale.shop'], o.price_type) |
37 | + ir_values_obj = self.pool.get('ir.values') |
38 | + for obj in self.browse(cr, uid, ids, context=context): |
39 | + ir_values_obj.set(cr, uid, 'default', False, 'price_type', ['sale.shop'], obj.price_type) |
40 | + |
41 | return { |
42 | - 'view_type': 'form', |
43 | - "view_mode": 'form', |
44 | - 'res_model': 'ir.actions.configuration.wizard', |
45 | - 'type': 'ir.actions.act_window', |
46 | - 'target': 'new', |
47 | - } |
48 | + 'view_type': 'form', |
49 | + "view_mode": 'form', |
50 | + 'res_model': 'ir.actions.configuration.wizard', |
51 | + 'type': 'ir.actions.act_window', |
52 | + 'target': 'new', |
53 | + } |
54 | |
55 | def action_cancel(self,cr,uid,ids,conect=None): |
56 | return { |
57 | - 'view_type': 'form', |
58 | - "view_mode": 'form', |
59 | - 'res_model': 'ir.actions.configuration.wizard', |
60 | - 'type': 'ir.actions.act_window', |
61 | - 'target':'new', |
62 | + 'view_type': 'form', |
63 | + "view_mode": 'form', |
64 | + 'res_model': 'ir.actions.configuration.wizard', |
65 | + 'type': 'ir.actions.act_window', |
66 | + 'target':'new', |
67 | } |
68 | |
69 | sale_shop_price_method_policy() |
70 | @@ -110,100 +112,54 @@ |
71 | _inherit = "product.product" |
72 | _description = "Product" |
73 | |
74 | - def _get_all_values(self, cr, uid, ids, name, arg, context={}): |
75 | + def _get_all_values(self, cr, uid, ids, name, arg, context=None): |
76 | res = {} |
77 | - product = ids |
78 | product_obj = self.pool.get('product.product') |
79 | - obj2 = self.pool.get('product.pricelist.item') |
80 | - obj = self.pool.get('product.pricelist') |
81 | - obj3 = self.pool.get('sale.order.line') |
82 | + pricelist_proxy = self.pool.get('product.pricelist') |
83 | + sol_proxy = self.pool.get('sale.order.line') |
84 | res_partner_obj = self.pool.get("res.partner") |
85 | - for line in product_obj.browse(cr, uid, product, context=context): |
86 | + for line in product_obj.browse(cr, uid, ids, context=context): |
87 | + c_price1, c_price2, list_price1, last_price, qty_last = 0.0, 0.0, 0.0, 0.0, 0.0 |
88 | + |
89 | partner = line.pi_partner_id.id |
90 | pricelist = line.pi_pricelist_id.id |
91 | qty1 = line.pi_quantity1 |
92 | qty2 = line.pi_quantity2 |
93 | if pricelist != False: |
94 | - val1 = obj.price_get(cr, uid, [pricelist], line.id, qty1, partner) |
95 | - for key,values in val1.items(): |
96 | - c_price1 = values |
97 | - val2 = obj.price_get(cr, uid, [pricelist], line.id, qty2, partner) |
98 | - for key,values in val2.items(): |
99 | - c_price2 = values |
100 | -# item_line = obj2.search(cr,uid,[]) |
101 | -# list = [] |
102 | -# for line2 in obj2.browse(cr, uid, item_line, context=context): |
103 | -# if line.id == line2.product_id.id: |
104 | -# list.append(line.min_quantity) |
105 | -# if list == []: |
106 | -# m_qty = 1.0 |
107 | -# else: |
108 | -# m_qty = max(list) |
109 | -# val3 = obj.price_get(cr, uid, [pricelist], line.id, m_qty, partner) |
110 | -# for key,values in val3.items(): |
111 | -# c_price3 = values |
112 | - sale_price_list = res_partner_obj.browse(cr, uid, partner).property_product_pricelist.id |
113 | - val_sale = obj.price_get(cr, uid, [sale_price_list], line.id, qty1, partner) |
114 | - for key,values in val_sale.items(): |
115 | - list_price1 = values |
116 | - read_id = obj3.search(cr,uid,[('product_id','=',line.id)]) |
117 | - if read_id == []: |
118 | - last_price = 0.0 |
119 | - qty_last = 0.0 |
120 | - last_list_price = 0.0 |
121 | - else: |
122 | - last_id = max(read_id) |
123 | - last_brw = obj3.browse(cr,uid,[last_id],context=context) |
124 | - for rec in last_brw: |
125 | - product2 = rec.product_id.id |
126 | - if line.id == product2: |
127 | - last_price = rec.price_unit |
128 | - qty_last = rec.product_uom_qty |
129 | -# val_last = obj.price_get(cr, uid,[pricelist], line.id, qty_last) |
130 | -# for key,values in val_last.items(): |
131 | -# last_list_price = values |
132 | - |
133 | - for id in ids: |
134 | - res[id] = {} |
135 | - if 'pi_customer_prices1' in name: |
136 | - res[id]['pi_customer_prices1'] = c_price1 |
137 | - if 'pi_customer_prices2' in name: |
138 | - res[id]['pi_customer_prices2'] = c_price2 |
139 | - if 'pi_list_prices1' in name: |
140 | - res[id]['pi_list_prices1'] = list_price1 |
141 | -# if 'pi_next_better_price_qty'in name: |
142 | -# res[id]['pi_next_better_price_qty']= m_qty |
143 | -# if 'pi_best_price_on_qty'in name: |
144 | -# res[id]['pi_best_price_on_qty']= c_price3 |
145 | - if 'pi_last_customer_prices'in name: |
146 | - res[id]['pi_last_customer_prices']= last_price |
147 | -# if 'pi_last_list_prices'in name: |
148 | -# res[id]['pi_last_list_prices']= last_list_price |
149 | - if 'pi_qty_buyed'in name: |
150 | - res[id]['pi_qty_buyed']= qty_last |
151 | - |
152 | - else: |
153 | - for id in ids: |
154 | - res[id] = {} |
155 | - if 'pi_customer_prices1' in name: |
156 | - res[id]['pi_customer_prices1'] = 0.0 |
157 | - if 'pi_customer_prices2' in name: |
158 | - res[id]['pi_customer_prices2'] = 0.0 |
159 | - if 'pi_list_prices1' in name: |
160 | - res[id]['pi_list_prices1'] = 0.0 |
161 | -# if 'pi_next_better_price_qty'in name: |
162 | -# res[id]['pi_next_better_price_qty']= 0.0 |
163 | -# if 'pi_best_price_on_qty'in name: |
164 | -# res[id]['pi_best_price_on_qty']= 0.0 |
165 | - if 'pi_last_customer_prices'in name: |
166 | - res[id]['pi_last_customer_prices']= 0.0 |
167 | -# if 'pi_last_list_prices'in name: |
168 | -# res[id]['pi_last_list_prices']= 0.0 |
169 | - if 'pi_qty_buyed'in name: |
170 | - res[id]['pi_qty_buyed']= 0.0 |
171 | + values = pricelist_proxy.price_get(cr, uid, [pricelist], line.id, qty1, partner) |
172 | + c_price1 = values[pricelist] |
173 | + |
174 | + values = pricelist_proxy.price_get(cr, uid, [pricelist], line.id, qty2, partner) |
175 | + c_price2 = values[pricelist] |
176 | + |
177 | + sale_price_list = res_partner_obj.browse(cr, uid, partner).property_product_pricelist.id |
178 | + values = pricelist_proxy.price_get(cr, uid, [sale_price_list], line.id, qty1, partner) |
179 | + list_price1 = values[sale_price_list] |
180 | + |
181 | + read_ids = sol_proxy.search(cr,uid,[('product_id','=',line.id)]) |
182 | + last_price, qty_last = 0.0, 0.0 |
183 | + if read_ids: |
184 | + last_id = max(read_ids) |
185 | + last_brw = sol_proxy.browse(cr,uid,[last_id],context=context) |
186 | + if line.id == last_brw[0].product_id.id: |
187 | + last_price = last_brw[0].price_unit |
188 | + qty_last = last_brw[0].product_uom_qty |
189 | + res[line.id] = {} |
190 | + |
191 | + if 'pi_customer_prices1' in name: |
192 | + res[line.id]['pi_customer_prices1'] = c_price1 or 0.0 |
193 | + if 'pi_customer_prices2' in name: |
194 | + res[line.id]['pi_customer_prices2'] = c_price2 or 0.0 |
195 | + if 'pi_list_prices1' in name: |
196 | + res[line.id]['pi_list_prices1'] = list_price1 or 0.0 |
197 | + if 'pi_last_customer_prices'in name: |
198 | + res[line.id]['pi_last_customer_prices']= last_price or 0.0 |
199 | + if 'pi_qty_buyed'in name: |
200 | + res[line.id]['pi_qty_buyed']= qty_last or 0.0 |
201 | + |
202 | return res |
203 | |
204 | - def button_dummy(self, cr, uid, ids, context={}): |
205 | + def button_dummy(self, cr, uid, ids, context=None): |
206 | return True |
207 | |
208 | _columns = { |
209 | @@ -214,15 +170,12 @@ |
210 | 'pi_customer_prices1': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices1',help='Costomer Price For Quantity1 & Quantity2'), |
211 | 'pi_customer_prices2': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices2'), |
212 | 'pi_list_prices1': fields.function(_get_all_values, method=True, type='float', string='List Prices',multi='pi_list_prices1',help= 'Price Of Public Pricelist'), |
213 | -# 'pi_next_better_price_qty': fields.function(_get_all_values, method=True, type='float', string='Next Better Price Qty',multi='pi_next_better_price_qty'), |
214 | -# 'pi_best_price_on_qty': fields.function(_get_all_values, method=True, type='float', string='Best Price On Quantity',multi='pi_best_price_on_qty'), |
215 | 'pi_last_customer_prices': fields.function(_get_all_values, method=True, type='float', string='Last Costomer Prices',multi='pi_last_customer_prices'), |
216 | -# 'pi_last_list_prices': fields.function(_get_all_values, method=True, type='float', string='Last List Prices',multi='pi_last_list_prices'), |
217 | 'pi_qty_buyed': fields.function(_get_all_values, method=True, type='float', string='Quantity Buyed',multi='pi_qty_buyed',help='Last Costomer Buyed Quantity'), |
218 | - } |
219 | + } |
220 | _defaults = { |
221 | 'pi_quantity1': lambda *a: 1.0, |
222 | 'pi_quantity2': lambda *a: 5.0, |
223 | - } |
224 | + } |
225 | product_product() |
226 | |
227 | |
228 | === modified file 'product_price_information/wizard/sale_prize_information.py' |
229 | --- product_price_information/wizard/sale_prize_information.py 2010-06-29 06:24:04 +0000 |
230 | +++ product_price_information/wizard/sale_prize_information.py 2010-07-19 15:15:54 +0000 |
231 | @@ -34,76 +34,55 @@ |
232 | 'customer_prices2':fields.float('Costomer Prices'), |
233 | 'last_customer_prices':fields.float('Last Costomer Prices'), |
234 | 'list_prices1':fields.float('List Prices',help= 'Price Of Public Pricelist'), |
235 | -# 'last_list_prices':fields.float('Last List Prices'), |
236 | -# 'next_better_price_qty':fields.float('Next Better Price Qty'), |
237 | -# 'best_price_on_qty':fields.float('Best Price On Quantity'), |
238 | 'qty_buyed':fields.float('Quantity Buyed',help='Last Costomer Buyed Quantity'), |
239 | - } |
240 | + } |
241 | + |
242 | _defaults = { |
243 | 'quantity1': lambda *a: 1.0, |
244 | 'quantity2': lambda *a: 5.0, |
245 | - } |
246 | + } |
247 | |
248 | def set_default(self, cr, uid, ids, context=None): |
249 | - obj = self.pool.get('product.pricelist') |
250 | - obj2 = self.pool.get('product.pricelist.item') |
251 | - obj3 = self.pool.get('sale.order.line') |
252 | - obj_product = self.pool.get("product.product") |
253 | - res_partner_obj = self.pool.get("res.partner") |
254 | - form = self.read(cr, uid, ids, [])[0] |
255 | - partner = form['partner_id'] |
256 | - pricelist = form['pricelist_id'] |
257 | - product = form['product_id'] |
258 | - qty1 = form['quantity1'] |
259 | - qty2 = form['quantity2'] |
260 | - val1 = obj.price_get(cr, uid, [pricelist], product, qty1, partner) |
261 | - for key,values in val1.items(): |
262 | - c_price1 = values |
263 | - val2 = obj.price_get(cr, uid, [pricelist], product, qty2, partner) |
264 | - for key,values in val2.items(): |
265 | - c_price2 = values |
266 | -# item_line = obj2.search(cr,uid,[]) |
267 | -# list = [] |
268 | -# for line in obj2.browse(cr, uid,item_line, context=context): |
269 | -# if product == line.product_id.id: |
270 | -# list.append(line.min_quantity) |
271 | -# if list == []: |
272 | -# m_qty = 1.0 |
273 | -# else: |
274 | -# m_qty = max(list) |
275 | -# val3 = obj.price_get(cr, uid, ids, product, m_qty, partner) |
276 | -# for key,values in val3.items(): |
277 | -# c_price3 = values |
278 | - sale_price_list = res_partner_obj.browse(cr, uid, partner).property_product_pricelist.id |
279 | - val_sale = obj.price_get(cr, uid, [sale_price_list], product, qty1, partner) |
280 | - for key,values in val_sale.items(): |
281 | - list_price1 = values |
282 | - read_id = obj3.search(cr,uid,[('product_id','=',product)]) |
283 | - if read_id == []: |
284 | - last_price = 0.0 |
285 | - qty_last = 0.0 |
286 | - last_list_price = 0.0 |
287 | - else: |
288 | - last_id = max(read_id) |
289 | - last_brw = obj3.browse(cr,uid,[last_id],context=context) |
290 | - for rec in last_brw: |
291 | - product2 = rec.product_id.id |
292 | - if product == product2: |
293 | - last_price = rec.price_unit |
294 | - qty_last = rec.product_uom_qty |
295 | -# val_last = obj.price_get(cr, uid,ids, product2, qty_last) |
296 | -# for key,values in val_last.items(): |
297 | -# last_list_price = values |
298 | -# self.write(cr , uid, ids,{'customer_prices1':c_price1,'customer_prices2':c_price2,'list_prices1':list_price1,'list_prices2':list_price2,'next_better_price_qty':m_qty,'best_price_on_qty':c_price3,'last_customer_prices':last_price,'qty_buyed':qty_last,'last_list_prices':last_list_price},context=context) |
299 | - self.write(cr , uid, ids,{'customer_prices1':c_price1,'customer_prices2':c_price2,'list_prices1':list_price1,'last_customer_prices':last_price,'qty_buyed':qty_last},context=context) |
300 | - value = { |
301 | - 'name': 'Sale Prize Information', |
302 | - 'view_type': 'form', |
303 | - 'view_mode': 'tree,form', |
304 | - 'res_model': 'sale.prize.information', |
305 | - 'type': 'ir.actions.act_window', |
306 | - } |
307 | + pricelist_proxy = self.pool.get('product.pricelist') |
308 | + sol_proxy = self.pool.get('sale.order.line') |
309 | + res_partner_proxy = self.pool.get("res.partner") |
310 | + form = self.read(cr, uid, ids, [])[0] |
311 | + partner = form['partner_id'] |
312 | + pricelist = form['pricelist_id'] |
313 | + product = form['product_id'] |
314 | + qty1 = form['quantity1'] |
315 | + qty2 = form['quantity2'] |
316 | + |
317 | + # Get the prices of the product |
318 | + values = pricelist_proxy.price_get(cr, uid, [pricelist], product, qty1, partner) |
319 | + c_price1 = values[pricelist] |
320 | + |
321 | + values = pricelist_proxy.price_get(cr, uid, [pricelist], product, qty2, partner) |
322 | + c_price2 = values[pricelist] |
323 | + |
324 | + sale_price_list = res_partner_proxy.browse(cr, uid, partner).property_product_pricelist.id |
325 | + values = pricelist_proxy.price_get(cr, uid, [sale_price_list], product, qty1, partner) |
326 | + list_price1 = values[sale_price_list] |
327 | + |
328 | + read_ids = sol_proxy.search(cr,uid,[('product_id','=',product)]) |
329 | + last_price, qty_last = 0.0, 0.0 |
330 | + if read_ids: |
331 | + last_id = max(read_ids) |
332 | + last_brw = sol_proxy.browse(cr,uid,[last_id],context=context) |
333 | + |
334 | + if product == last_brw[0].product_id.id: |
335 | + last_price = last_brw[0].price_unit |
336 | + qty_last = last_brw[0].product_uom_qty |
337 | + |
338 | + values = { |
339 | + 'customer_prices1':c_price1, |
340 | + 'customer_prices2':c_price2, |
341 | + 'list_prices1':list_price1, |
342 | + 'last_customer_prices':last_price, |
343 | + 'qty_buyed':qty_last |
344 | + } |
345 | + self.write(cr , uid, ids, values, context=context) |
346 | |
347 | sale_prize_information() |
348 | |
349 | -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
350 | \ No newline at end of file |
351 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
352 | |
353 | === modified file 'product_price_information/wizard/sale_prize_information_view.xml' |
354 | --- product_price_information/wizard/sale_prize_information_view.xml 2010-06-25 10:12:24 +0000 |
355 | +++ product_price_information/wizard/sale_prize_information_view.xml 2010-07-19 15:15:54 +0000 |
356 | @@ -1,7 +1,7 @@ |
357 | <?xml version="1.0" encoding="utf-8"?> |
358 | <openerp> |
359 | <data> |
360 | - <record id="view_sale_prize_information" model="ir.ui.view"> |
361 | + <record id="view_sale_prize_information" model="ir.ui.view"> |
362 | <field name="name">Sale Prize Information</field> |
363 | <field name="model">sale.prize.information</field> |
364 | <field name="type">form</field> |
365 | @@ -18,44 +18,41 @@ |
366 | <field name="customer_prices2" nolabel="1"/> |
367 | <field name="list_prices1"/> |
368 | </group> |
369 | -<!-- <field name="next_better_price_qty"/>--> |
370 | -<!-- <field name="best_price_on_qty"/>--> |
371 | - <newline/> |
372 | + <newline/> |
373 | </group> |
374 | <group col="2" colspan="3"> |
375 | <field name="pricelist_id"/> |
376 | - <group col="4" colspan="2"> |
377 | - <field name="quantity1"/> |
378 | - <field name="quantity2"/> |
379 | - </group> |
380 | - <separator string="Price on Last Sale"/> |
381 | - <newline/> |
382 | - <field name="last_customer_prices"/> |
383 | -<!-- <field name="last_list_prices"/>--> |
384 | - <field name="qty_buyed"/> |
385 | - </group> |
386 | - </group> |
387 | - <group col="2" colspan="4"> |
388 | - <button icon="gtk-cancel" special="cancel" string="Cancel" /> |
389 | - <button icon="gtk-ok" string="Calculate" name="set_default" type="object"/> |
390 | - </group> |
391 | - </form> |
392 | + <group col="4" colspan="2"> |
393 | + <field name="quantity1"/> |
394 | + <field name="quantity2"/> |
395 | + </group> |
396 | + <separator string="Price on Last Sale"/> |
397 | + <newline/> |
398 | + <field name="last_customer_prices"/> |
399 | + <field name="qty_buyed"/> |
400 | + </group> |
401 | + </group> |
402 | + <group col="2" colspan="4"> |
403 | + <button icon="gtk-cancel" special="cancel" string="Cancel" /> |
404 | + <button icon="gtk-ok" string="Calculate" name="set_default" type="object"/> |
405 | + </group> |
406 | + </form> |
407 | </field> |
408 | </record> |
409 | |
410 | - <record id="action_sale_prize_information" model="ir.actions.act_window"> |
411 | + <record id="action_sale_prize_information" model="ir.actions.act_window"> |
412 | <field name="name">Sale Price Information</field> |
413 | <field name="type">ir.actions.act_window</field> |
414 | <field name="res_model">sale.prize.information</field> |
415 | <field name="view_type">form</field> |
416 | <field name="view_mode">form</field> |
417 | - <field name="view_id" ref="view_sale_prize_information"/> |
418 | - <field name="target">new</field> |
419 | + <field name="view_id" ref="view_sale_prize_information"/> |
420 | + <field name="target">new</field> |
421 | </record> |
422 | |
423 | - <menuitem action="action_sale_prize_information" |
424 | - id="menu_sale_prize_information" |
425 | - parent="sale.menu_sale_root"/> |
426 | + <menuitem action="action_sale_prize_information" |
427 | + id="menu_sale_prize_information" |
428 | + parent="sale.menu_sale_root"/> |
429 | |
430 | - </data> |
431 | -</openerp> |
432 | \ No newline at end of file |
433 | + </data> |
434 | +</openerp> |
435 | |
436 | === modified file 'sales_shop_stock_availability/sales_shop_stock_availability.py' |
437 | --- sales_shop_stock_availability/sales_shop_stock_availability.py 2010-06-29 13:31:14 +0000 |
438 | +++ sales_shop_stock_availability/sales_shop_stock_availability.py 2010-07-19 15:15:54 +0000 |
439 | @@ -26,17 +26,19 @@ |
440 | class product_product(osv.osv): |
441 | _inherit = "product.product" |
442 | |
443 | - def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}): |
444 | + def _product_available(self, cr, uid, ids, field_names=None, arg=False, context=None): |
445 | res = {} |
446 | product_obj = self.pool.get('product.product') |
447 | common_ids = product_obj.search(cr,uid,[('common_product','=',True),('id','in',ids)]) |
448 | simple_ids = product_obj.search(cr,uid,[('common_product','=',False),('id','in',ids)]) |
449 | - res = super(product_product,self)._product_available(cr, uid, common_ids, field_names, arg, context={}) |
450 | + res = super(product_product,self)._product_available(cr, uid, common_ids, field_names, arg, context=context) |
451 | res2 = super(product_product,self)._product_available(cr, uid, simple_ids, field_names, arg, context=context) |
452 | res.update(res2) |
453 | return res |
454 | |
455 | - def _product_available_other_shop(self, cr, uid, ids, name, arg, context={}): |
456 | + def _product_available_other_shop(self, cr, uid, ids, name, arg, context=None): |
457 | + if context is None: |
458 | + context = {} |
459 | res = {} |
460 | product_obj = self.pool.get('product.product') |
461 | common_id = product_obj.search(cr,uid,[('common_product','=',True),('id','in',ids)]) |
462 | @@ -46,7 +48,7 @@ |
463 | real_res = {} |
464 | virtual_res = {} |
465 | if common_id: |
466 | - stock_common = product_obj._product_available(cr, uid, common_id ,fields_name, context={}) |
467 | + stock_common = product_obj._product_available(cr, uid, common_id ,fields_name, context=context) |
468 | for key,value in stock_common.items(): |
469 | real_res[key] = stock_common[key]['qty_available'] |
470 | virtual_res[key] = stock_common[key]['virtual_available'] |
471 | @@ -72,8 +74,7 @@ |
472 | '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'), |
473 | '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'), |
474 | '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'), |
475 | - |
476 | - } |
477 | + } |
478 | |
479 | product_product() |
480 | |
481 | |
482 | === modified file 'sales_shop_stock_availability/wizard/stock_shop_availability.py' |
483 | --- sales_shop_stock_availability/wizard/stock_shop_availability.py 2010-06-29 12:57:57 +0000 |
484 | +++ sales_shop_stock_availability/wizard/stock_shop_availability.py 2010-07-19 15:15:54 +0000 |
485 | @@ -31,7 +31,7 @@ |
486 | 'virtual_stock': fields.float('Virtual Stock',help="Current virtual quantities of products selected shop in sale order."), |
487 | 'other_shop_real_stock': fields.float('Other Shop Real Stock',help="Current quantities of products in other stock location except selected shop in sale order."), |
488 | 'other_shop_virtual_stock': fields.float('Other Shop Virtual Stock',help="Current virtual quantities of products in other stock location except selected shop in sale order."), |
489 | - } |
490 | + } |
491 | |
492 | def product_available_other_shop(self, cr, uid, ids, context=None): |
493 | form = self.read(cr, uid, ids, [])[0] |
494 | @@ -41,32 +41,30 @@ |
495 | common_id = product_obj.browse(cr, uid, product_id ,context=context).common_product |
496 | fields_name = ['qty_available','virtual_available'] |
497 | if common_id: |
498 | - stock_common = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={}) |
499 | - for key,value in stock_common.items(): |
500 | - real_val1 = value['qty_available'] |
501 | - virt_val1 = value['virtual_available'] |
502 | - other_real_val = value['qty_available'] |
503 | - other_virt_val = value['virtual_available'] |
504 | + stock_common = product_obj._product_available(cr, uid, [product_id] ,fields_name,context=context) |
505 | + |
506 | + real_val1 = stock_common[product_id]['qty_available'] |
507 | + virt_val1 = stock_common[product_id]['virtual_available'] |
508 | + other_real_val = stock_common[product_id]['qty_available'] |
509 | + other_virt_val = stock_common[product_id]['virtual_available'] |
510 | else: |
511 | - stock2 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context={}) |
512 | + stock2 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context=context) |
513 | + real_val2 = stock2[product_id]['qty_available'] |
514 | + virt_val2 = stock2[product_id]['virtual_available'] |
515 | + |
516 | context.update({'shop':shop_id,'product_id':product_id}) |
517 | stock1 = product_obj._product_available(cr, uid, [product_id] ,fields_name,context=context) |
518 | - for key,value in stock1.items(): |
519 | - real_val1 = value['qty_available'] |
520 | - virt_val1 = value['virtual_available'] |
521 | - for key,value in stock2.items(): |
522 | - real_val2 = value['qty_available'] |
523 | - virt_val2 = value['virtual_available'] |
524 | + real_val1 = stock1[product_id]['qty_available'] |
525 | + virt_val1 = stock1[product_id]['virtual_available'] |
526 | + |
527 | other_real_val = real_val2 - real_val1 |
528 | other_virt_val = virt_val2 - virt_val1 |
529 | - for id in ids: |
530 | - self.write(cr, uid, [id],{ |
531 | - 'real_stock':real_val1, |
532 | - 'virtual_stock':virt_val1, |
533 | - 'other_shop_real_stock':other_real_val, |
534 | - 'other_shop_virtual_stock':other_virt_val, |
535 | |
536 | - }) |
537 | + self.write(cr, uid, ids, {'real_stock':real_val1, |
538 | + 'virtual_stock':virt_val1, |
539 | + 'other_shop_real_stock':other_real_val, |
540 | + 'other_shop_virtual_stock':other_virt_val, |
541 | + }) |
542 | return True |
543 | |
544 | stock_shop_availability() |