Merge lp:~openbig/bigconsulting/functional_field_add_in_product_tab into lp:bigconsulting
- functional_field_add_in_product_tab
- Merge into addons
Proposed by
Atik Agewan(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 28 |
Proposed branch: | lp:~openbig/bigconsulting/functional_field_add_in_product_tab |
Merge into: | lp:bigconsulting |
Diff against target: |
409 lines (+219/-59) 3 files modified
product_price_information/product_price_info.py (+136/-13) product_price_information/product_price_info_view.xml (+48/-11) product_price_information/wizard/sale_prize_information_view.xml (+35/-35) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/functional_field_add_in_product_tab |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+28188@code.launchpad.net |
Commit message
Description of the change
Functional field are added in product tab.....
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-05-26 14:22:22 +0000 |
3 | +++ product_price_information/product_price_info.py 2010-06-22 14:09:30 +0000 |
4 | @@ -1,7 +1,7 @@ |
5 | # -*- encoding: utf-8 -*- |
6 | ############################################################################## |
7 | # |
8 | -# OpenERP, Open Source Management Solution |
9 | +# OpenERP, Open Source Management Solution |
10 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
11 | # $Id$ |
12 | # |
13 | @@ -21,20 +21,20 @@ |
14 | ############################################################################## |
15 | from osv import fields, osv |
16 | from tools import config |
17 | - |
18 | + |
19 | class sale_order_line(osv.osv): |
20 | _inherit = "sale.order.line" |
21 | |
22 | _columns = { |
23 | 'sale_price_unit_tax': fields.float('Sale price W/O taxes'), |
24 | } |
25 | - |
26 | + |
27 | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, |
28 | uom=False, qty_uos=0, uos=False, name='', partner_id=False, |
29 | lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): |
30 | - |
31 | + |
32 | tax_obj = self.pool.get('account.tax') |
33 | - |
34 | + |
35 | result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, |
36 | uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging, fiscal_position, flag) |
37 | if product: |
38 | @@ -43,19 +43,19 @@ |
39 | result['value']['sale_price_unit_tax'] = product_obj.product_tmpl_id.price_unit_tax |
40 | |
41 | return result |
42 | - |
43 | + |
44 | sale_order_line() |
45 | |
46 | class sale_order(osv.osv): |
47 | _name = "sale.order" |
48 | _inherit = "sale.order" |
49 | - |
50 | + |
51 | def onchange_shop_id(self, cr, uid, ids, shop_id): |
52 | res = super(sale_order, self).onchange_shop_id(cr, uid, id, shop_id) |
53 | if 'value' in res and shop_id: |
54 | res['value']['price_type'] = self.pool.get('sale.shop').browse(cr, uid , shop_id).price_type |
55 | return res |
56 | - |
57 | + |
58 | sale_order() |
59 | |
60 | |
61 | @@ -86,7 +86,7 @@ |
62 | _defaults = { |
63 | 'price_type': lambda *a: 'tax_included', |
64 | } |
65 | - |
66 | + |
67 | def set_default(self, cr, uid, ids, context=None): |
68 | for o in self.browse(cr, uid, ids, context=context): |
69 | ir_values_obj = self.pool.get('ir.values') |
70 | @@ -97,8 +97,8 @@ |
71 | 'res_model': 'ir.actions.configuration.wizard', |
72 | 'type': 'ir.actions.act_window', |
73 | 'target': 'new', |
74 | - } |
75 | - |
76 | + } |
77 | + |
78 | def action_cancel(self,cr,uid,ids,conect=None): |
79 | return { |
80 | 'view_type': 'form', |
81 | @@ -107,5 +107,128 @@ |
82 | 'type': 'ir.actions.act_window', |
83 | 'target':'new', |
84 | } |
85 | - |
86 | -sale_shop_price_method_policy() |
87 | \ No newline at end of file |
88 | + |
89 | +sale_shop_price_method_policy() |
90 | + |
91 | + |
92 | +class product_product(osv.osv): |
93 | + _name = "product.product" |
94 | + _inherit = "product.product" |
95 | + _description = "Product" |
96 | + |
97 | + def _get_all_values(self, cr, uid, ids, name, arg, context={}): |
98 | + res = {} |
99 | + product = ids |
100 | + product_obj = self.pool.get('product.product') |
101 | + obj2 = self.pool.get('product.pricelist.item') |
102 | + obj = self.pool.get('product.pricelist') |
103 | + obj3 = self.pool.get('sale.order.line') |
104 | + for line in product_obj.browse(cr, uid, product, context=context): |
105 | + partner = line.pi_partner_id.id |
106 | + pricelist = line.pi_pricelist_id.id |
107 | + qty1 = line.pi_quantity1 |
108 | + qty2 = line.pi_quantity2 |
109 | + if pricelist != False: |
110 | + val1 = obj.price_get(cr, uid, [pricelist], line.id, qty1, partner) |
111 | + for key,values in val1.items(): |
112 | + c_price1 = values |
113 | + val2 = obj.price_get(cr, uid, [pricelist], line.id, qty2, partner) |
114 | + for key,values in val2.items(): |
115 | + c_price2 = values |
116 | + item_line = obj2.search(cr,uid,[]) |
117 | + list = [] |
118 | + for line2 in obj2.browse(cr, uid, item_line, context=context): |
119 | + if line.id == line2.product_id.id: |
120 | + list.append(line.min_quantity) |
121 | + if list == []: |
122 | + m_qty = 1.0 |
123 | + else: |
124 | + m_qty = max(list) |
125 | + val3 = obj.price_get(cr, uid, [pricelist], line.id, m_qty, partner) |
126 | + for key,values in val3.items(): |
127 | + c_price3 = values |
128 | + list_price = product_obj.browse(cr, uid, line.id).standard_price |
129 | + list_price1 = list_price * qty1 |
130 | + list_price2 = list_price * qty2 |
131 | + read_id = obj3.search(cr,uid,[('product_id','=',line.id)]) |
132 | + if read_id == []: |
133 | + last_price = 0.0 |
134 | + qty_last = 0.0 |
135 | + last_list_price = 0.0 |
136 | + else: |
137 | + last_id = max(read_id) |
138 | + last_brw = obj3.browse(cr,uid,[last_id],context=context) |
139 | + for rec in last_brw: |
140 | + product2 = rec.product_id.id |
141 | + if line.id == product2: |
142 | + last_price = rec.price_unit |
143 | + qty_last = rec.product_uom_qty |
144 | + val_last = obj.price_get(cr, uid,[pricelist], line.id, qty_last) |
145 | + for key,values in val_last.items(): |
146 | + last_list_price = values |
147 | + |
148 | + for id in ids: |
149 | + res[id] = {} |
150 | + if 'pi_customer_prices1' in name: |
151 | + res[id]['pi_customer_prices1'] = c_price1 |
152 | + if 'pi_customer_prices2' in name: |
153 | + res[id]['pi_customer_prices2'] = c_price2 |
154 | + if 'pi_list_prices1' in name: |
155 | + res[id]['pi_list_prices1'] = list_price1 |
156 | + if 'pi_list_prices2'in name: |
157 | + res[id]['pi_list_prices2']= list_price2 |
158 | + if 'pi_next_better_price_qty'in name: |
159 | + res[id]['pi_next_better_price_qty']= m_qty |
160 | + if 'pi_best_price_on_qty'in name: |
161 | + res[id]['pi_best_price_on_qty']= c_price3 |
162 | + if 'pi_last_customer_prices'in name: |
163 | + res[id]['pi_last_customer_prices']= last_price |
164 | + if 'pi_last_list_prices'in name: |
165 | + res[id]['pi_last_list_prices']= last_list_price |
166 | + if 'pi_qty_buyed'in name: |
167 | + res[id]['pi_qty_buyed']= qty_last |
168 | + |
169 | + else: |
170 | + for id in ids: |
171 | + res[id] = {} |
172 | + if 'pi_customer_prices1' in name: |
173 | + res[id]['pi_customer_prices1'] = 0.0 |
174 | + if 'pi_customer_prices2' in name: |
175 | + res[id]['pi_customer_prices2'] = 0.0 |
176 | + if 'pi_list_prices1' in name: |
177 | + res[id]['pi_list_prices1'] = 0.0 |
178 | + if 'pi_list_prices2'in name: |
179 | + res[id]['pi_list_prices2']= 0.0 |
180 | + if 'pi_next_better_price_qty'in name: |
181 | + res[id]['pi_next_better_price_qty']= 0.0 |
182 | + if 'pi_best_price_on_qty'in name: |
183 | + res[id]['pi_best_price_on_qty']= 0.0 |
184 | + if 'pi_last_customer_prices'in name: |
185 | + res[id]['pi_last_customer_prices']= 0.0 |
186 | + if 'pi_last_list_prices'in name: |
187 | + res[id]['pi_last_list_prices']= 0.0 |
188 | + if 'pi_qty_buyed'in name: |
189 | + res[id]['pi_qty_buyed']= 0.0 |
190 | + return res |
191 | + |
192 | + _columns = { |
193 | + 'pi_quantity1': fields.float('Quantity1'), |
194 | + 'pi_quantity2': fields.float('Quantity2'), |
195 | + 'pi_pricelist_id': fields.many2one('product.pricelist', 'Pricelist'), |
196 | + 'pi_partner_id': fields.many2one('res.partner', 'Customer'), |
197 | + 'pi_customer_prices1': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices1'), |
198 | + 'pi_customer_prices2': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices2'), |
199 | + 'pi_list_prices1': fields.function(_get_all_values, method=True, type='float', string='List Prices',multi='pi_list_prices1'), |
200 | + 'pi_list_prices2': fields.function(_get_all_values, method=True, type='float', string='List Prices',multi='pi_list_prices2'), |
201 | + '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'), |
202 | + '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'), |
203 | + 'pi_last_customer_prices': fields.function(_get_all_values, method=True, type='float', string='Last Costomer Prices',multi='pi_last_customer_prices'), |
204 | + 'pi_last_list_prices': fields.function(_get_all_values, method=True, type='float', string='Last List Prices',multi='pi_last_list_prices'), |
205 | + 'pi_qty_buyed': fields.function(_get_all_values, method=True, type='float', string='Quantity Buyed',multi='pi_qty_buyed'), |
206 | + } |
207 | + _defaults = { |
208 | + 'pi_quantity1': lambda *a: 1.0, |
209 | + 'pi_quantity2': lambda *a: 5.0, |
210 | + } |
211 | +product_product() |
212 | + |
213 | |
214 | === modified file 'product_price_information/product_price_info_view.xml' |
215 | --- product_price_information/product_price_info_view.xml 2010-05-20 14:03:55 +0000 |
216 | +++ product_price_information/product_price_info_view.xml 2010-06-22 14:09:30 +0000 |
217 | @@ -1,9 +1,7 @@ |
218 | <?xml version="1.0" ?> |
219 | <openerp> |
220 | - <data> |
221 | - |
222 | -<!-- Adding shop price field on sale order line form below Unit Price --> |
223 | - |
224 | + <data> |
225 | + <!-- Adding shop price field on sale order line form below Unit Price --> |
226 | <record model="ir.ui.view" id="view_sale_order_line_tree_direct_delivery"> |
227 | <field name="name">sale.order.form2</field> |
228 | <field name="model">sale.order</field> |
229 | @@ -15,7 +13,7 @@ |
230 | </xpath> |
231 | </field> |
232 | </record> |
233 | - |
234 | + |
235 | <record model="ir.ui.view" id="product_tax_include_tree"> |
236 | <field name="name">product.tax.include.tree</field> |
237 | <field name="model">product.product</field> |
238 | @@ -27,19 +25,58 @@ |
239 | </field> |
240 | </field> |
241 | </record> |
242 | - |
243 | + |
244 | <record id="view_partner_property_form" model="ir.ui.view"> |
245 | <field name="name">sale.shop.property.form.inherit</field> |
246 | <field name="model">sale.shop</field> |
247 | <field name="type">form</field> |
248 | <field name="inherit_id" ref="sale.view_shop_form"/> |
249 | <field name="arch" type="xml"> |
250 | - <field name="project_id" position="after"> |
251 | + <field name="project_id" position="after"> |
252 | <field name="price_type"/> |
253 | </field> |
254 | </field> |
255 | </record> |
256 | - |
257 | + |
258 | + <!--product.product inherit view --> |
259 | + <record id="product_product_price_information_inherit" model="ir.ui.view"> |
260 | + <field name="name">product.product.price.information.inherit</field> |
261 | + <field name="model">product.product</field> |
262 | + <field name="type">form</field> |
263 | + <field name="inherit_id" ref="product.product_normal_form_view"/> |
264 | + <field name="arch" type="xml"> |
265 | + <notebook colspan="4" position="inside"> |
266 | + <page string='Price Information'> |
267 | + <field name="pi_partner_id"/> |
268 | + <field name="pi_pricelist_id"/> |
269 | + <field name="pi_quantity1"/> |
270 | + <field name="pi_quantity2"/> |
271 | + <newline/> |
272 | + <group col="6" colspan="4"> |
273 | + <group col="4" colspan="3"> |
274 | + <separator string="Prices of Product" colspan="2"/> |
275 | + <newline/> |
276 | + <field name="pi_customer_prices1"/> |
277 | + <field name="pi_customer_prices2" nolabel="1"/> |
278 | + <field name="pi_list_prices1"/> |
279 | + <field name="pi_list_prices2" nolabel="1"/> |
280 | + <field name="pi_next_better_price_qty"/> |
281 | + <newline/> |
282 | + <field name="pi_best_price_on_qty"/> |
283 | + </group> |
284 | + <group col="3" colspan="3"> |
285 | + <separator string="Price on Last Sale" colspan="2"/> |
286 | + <newline/> |
287 | + <field name="pi_last_customer_prices"/> |
288 | + <field name="pi_last_list_prices"/> |
289 | + <field name="pi_qty_buyed"/> |
290 | + </group> |
291 | + </group> |
292 | + </page> |
293 | + </notebook> |
294 | + </field> |
295 | + </record> |
296 | + |
297 | <record id="view_config_price_policy" model="ir.ui.view"> |
298 | <field name="name">Price Method for Sale Order Shop</field> |
299 | <field name="model">sale.shop.price.method</field> |
300 | @@ -55,7 +92,7 @@ |
301 | </form> |
302 | </field> |
303 | </record> |
304 | - |
305 | + |
306 | <record id="action_config_price_policy" model="ir.actions.act_window"> |
307 | <field name="name">Price Method for Sale Order Shop</field> |
308 | <field name="type">ir.actions.act_window</field> |
309 | @@ -64,12 +101,12 @@ |
310 | <field name="view_mode">form</field> |
311 | <field name="target">new</field> |
312 | </record> |
313 | - |
314 | + |
315 | <record id="config_wizard_step_shop_price_policy" model="ir.actions.todo"> |
316 | <field name="name">Shop Price</field> |
317 | <field name="note">This Configuration step use to set default price type for shop.</field> |
318 | <field name="action_id" ref="action_config_price_policy"/> |
319 | </record> |
320 | - |
321 | + |
322 | </data> |
323 | </openerp> |
324 | |
325 | === modified file 'product_price_information/wizard/sale_prize_information_view.xml' |
326 | --- product_price_information/wizard/sale_prize_information_view.xml 2010-06-09 10:37:58 +0000 |
327 | +++ product_price_information/wizard/sale_prize_information_view.xml 2010-06-22 14:09:30 +0000 |
328 | @@ -6,46 +6,46 @@ |
329 | <field name="model">sale.prize.information</field> |
330 | <field name="type">form</field> |
331 | <field name="arch" type="xml"> |
332 | - <form string="Sale Prize Information"> |
333 | - <group col="6" colspan="4"> |
334 | - <group col="2" colspan="3"> |
335 | - <field name="partner_id"/> |
336 | - <field name="product_id"/> |
337 | - <separator string="Prices of Product"/> |
338 | - <newline/> |
339 | - <group col="4" colspan="2"> |
340 | - <field name="customer_prices1"/> |
341 | - <field name="customer_prices2" string=""/> |
342 | - <field name="list_prices1"/> |
343 | - <field name="list_prices2" string=""/> |
344 | + <form string="Sale Prize Information"> |
345 | + <group col="6" colspan="4"> |
346 | + <group col="2" colspan="3"> |
347 | + <field name="partner_id"/> |
348 | + <field name="product_id"/> |
349 | + <separator string="Prices of Product"/> |
350 | + <newline/> |
351 | + <group col="4" colspan="2"> |
352 | + <field name="customer_prices1"/> |
353 | + <field name="customer_prices2" nolabel="1"/> |
354 | + <field name="list_prices1"/> |
355 | + <field name="list_prices2" nolabel="1"/> |
356 | + </group> |
357 | + <field name="next_better_price_qty"/> |
358 | + <field name="best_price_on_qty"/> |
359 | + <newline/> |
360 | + </group> |
361 | + <group col="2" colspan="3"> |
362 | + <field name="pricelist_id"/> |
363 | + <group col="4" colspan="2"> |
364 | + <field name="quantity1"/> |
365 | + <field name="quantity2"/> |
366 | + </group> |
367 | + <separator string="Price on Last Sale"/> |
368 | + <newline/> |
369 | + <field name="last_customer_prices"/> |
370 | + <field name="last_list_prices"/> |
371 | + <field name="qty_buyed"/> |
372 | </group> |
373 | - <field name="next_better_price_qty"/> |
374 | - <field name="best_price_on_qty"/> |
375 | - <newline/> |
376 | - </group> |
377 | - <group col="2" colspan="3"> |
378 | - <field name="pricelist_id"/> |
379 | - <group col="4" colspan="2"> |
380 | - <field name="quantity1"/> |
381 | - <field name="quantity2"/> |
382 | - </group> |
383 | - <separator string="Price on Last Sale"/> |
384 | - <newline/> |
385 | - <field name="last_customer_prices"/> |
386 | - <field name="last_list_prices"/> |
387 | - <field name="qty_buyed"/> |
388 | - </group> |
389 | - </group> |
390 | - <group col="2" colspan="4"> |
391 | - <button icon='gtk-cancel' special="cancel" string="Cancel" /> |
392 | - <button icon="gtk-ok" string="Calculate" name="set_default" type="object" /> |
393 | - </group> |
394 | - </form> |
395 | + </group> |
396 | + <group col="2" colspan="4"> |
397 | + <button icon="gtk-cancel" special="cancel" string="Cancel" /> |
398 | + <button icon="gtk-ok" string="Calculate" name="set_default" type="object"/> |
399 | + </group> |
400 | + </form> |
401 | </field> |
402 | </record> |
403 | |
404 | <record id="action_sale_prize_information" model="ir.actions.act_window"> |
405 | - <field name="name">Sale Prize Information</field> |
406 | + <field name="name">Sale Price Information</field> |
407 | <field name="type">ir.actions.act_window</field> |
408 | <field name="res_model">sale.prize.information</field> |
409 | <field name="view_type">form</field> |