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

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
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+28188@code.launchpad.net

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
=== modified file 'product_price_information/product_price_info.py'
--- product_price_information/product_price_info.py 2010-05-26 14:22:22 +0000
+++ product_price_information/product_price_info.py 2010-06-22 14:09:30 +0000
@@ -1,7 +1,7 @@
1# -*- encoding: utf-8 -*-1# -*- encoding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# OpenERP, Open Source Management Solution 4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$6# $Id$
7#7#
@@ -21,20 +21,20 @@
21##############################################################################21##############################################################################
22from osv import fields, osv22from osv import fields, osv
23from tools import config23from tools import config
24 24
25class sale_order_line(osv.osv):25class sale_order_line(osv.osv):
26 _inherit = "sale.order.line"26 _inherit = "sale.order.line"
2727
28 _columns = {28 _columns = {
29 'sale_price_unit_tax': fields.float('Sale price W/O taxes'),29 'sale_price_unit_tax': fields.float('Sale price W/O taxes'),
30 }30 }
31 31
32 def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,32 def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
33 uom=False, qty_uos=0, uos=False, name='', partner_id=False,33 uom=False, qty_uos=0, uos=False, name='', partner_id=False,
34 lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False):34 lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False):
35 35
36 tax_obj = self.pool.get('account.tax')36 tax_obj = self.pool.get('account.tax')
37 37
38 result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty,38 result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty,
39 uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging, fiscal_position, flag)39 uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging, fiscal_position, flag)
40 if product:40 if product:
@@ -43,19 +43,19 @@
43 result['value']['sale_price_unit_tax'] = product_obj.product_tmpl_id.price_unit_tax43 result['value']['sale_price_unit_tax'] = product_obj.product_tmpl_id.price_unit_tax
4444
45 return result45 return result
46 46
47sale_order_line()47sale_order_line()
4848
49class sale_order(osv.osv):49class sale_order(osv.osv):
50 _name = "sale.order"50 _name = "sale.order"
51 _inherit = "sale.order"51 _inherit = "sale.order"
52 52
53 def onchange_shop_id(self, cr, uid, ids, shop_id):53 def onchange_shop_id(self, cr, uid, ids, shop_id):
54 res = super(sale_order, self).onchange_shop_id(cr, uid, id, shop_id)54 res = super(sale_order, self).onchange_shop_id(cr, uid, id, shop_id)
55 if 'value' in res and shop_id:55 if 'value' in res and shop_id:
56 res['value']['price_type'] = self.pool.get('sale.shop').browse(cr, uid , shop_id).price_type56 res['value']['price_type'] = self.pool.get('sale.shop').browse(cr, uid , shop_id).price_type
57 return res57 return res
58 58
59sale_order()59sale_order()
6060
6161
@@ -86,7 +86,7 @@
86 _defaults = {86 _defaults = {
87 'price_type': lambda *a: 'tax_included',87 'price_type': lambda *a: 'tax_included',
88 }88 }
89 89
90 def set_default(self, cr, uid, ids, context=None):90 def set_default(self, cr, uid, ids, context=None):
91 for o in self.browse(cr, uid, ids, context=context):91 for o in self.browse(cr, uid, ids, context=context):
92 ir_values_obj = self.pool.get('ir.values')92 ir_values_obj = self.pool.get('ir.values')
@@ -97,8 +97,8 @@
97 'res_model': 'ir.actions.configuration.wizard',97 'res_model': 'ir.actions.configuration.wizard',
98 'type': 'ir.actions.act_window',98 'type': 'ir.actions.act_window',
99 'target': 'new',99 'target': 'new',
100 } 100 }
101 101
102 def action_cancel(self,cr,uid,ids,conect=None):102 def action_cancel(self,cr,uid,ids,conect=None):
103 return {103 return {
104 'view_type': 'form',104 'view_type': 'form',
@@ -107,5 +107,128 @@
107 'type': 'ir.actions.act_window',107 'type': 'ir.actions.act_window',
108 'target':'new',108 'target':'new',
109 }109 }
110
111sale_shop_price_method_policy()
112\ No newline at end of file110\ No newline at end of file
111
112sale_shop_price_method_policy()
113
114
115class product_product(osv.osv):
116 _name = "product.product"
117 _inherit = "product.product"
118 _description = "Product"
119
120 def _get_all_values(self, cr, uid, ids, name, arg, context={}):
121 res = {}
122 product = ids
123 product_obj = self.pool.get('product.product')
124 obj2 = self.pool.get('product.pricelist.item')
125 obj = self.pool.get('product.pricelist')
126 obj3 = self.pool.get('sale.order.line')
127 for line in product_obj.browse(cr, uid, product, context=context):
128 partner = line.pi_partner_id.id
129 pricelist = line.pi_pricelist_id.id
130 qty1 = line.pi_quantity1
131 qty2 = line.pi_quantity2
132 if pricelist != False:
133 val1 = obj.price_get(cr, uid, [pricelist], line.id, qty1, partner)
134 for key,values in val1.items():
135 c_price1 = values
136 val2 = obj.price_get(cr, uid, [pricelist], line.id, qty2, partner)
137 for key,values in val2.items():
138 c_price2 = values
139 item_line = obj2.search(cr,uid,[])
140 list = []
141 for line2 in obj2.browse(cr, uid, item_line, context=context):
142 if line.id == line2.product_id.id:
143 list.append(line.min_quantity)
144 if list == []:
145 m_qty = 1.0
146 else:
147 m_qty = max(list)
148 val3 = obj.price_get(cr, uid, [pricelist], line.id, m_qty, partner)
149 for key,values in val3.items():
150 c_price3 = values
151 list_price = product_obj.browse(cr, uid, line.id).standard_price
152 list_price1 = list_price * qty1
153 list_price2 = list_price * qty2
154 read_id = obj3.search(cr,uid,[('product_id','=',line.id)])
155 if read_id == []:
156 last_price = 0.0
157 qty_last = 0.0
158 last_list_price = 0.0
159 else:
160 last_id = max(read_id)
161 last_brw = obj3.browse(cr,uid,[last_id],context=context)
162 for rec in last_brw:
163 product2 = rec.product_id.id
164 if line.id == product2:
165 last_price = rec.price_unit
166 qty_last = rec.product_uom_qty
167 val_last = obj.price_get(cr, uid,[pricelist], line.id, qty_last)
168 for key,values in val_last.items():
169 last_list_price = values
170
171 for id in ids:
172 res[id] = {}
173 if 'pi_customer_prices1' in name:
174 res[id]['pi_customer_prices1'] = c_price1
175 if 'pi_customer_prices2' in name:
176 res[id]['pi_customer_prices2'] = c_price2
177 if 'pi_list_prices1' in name:
178 res[id]['pi_list_prices1'] = list_price1
179 if 'pi_list_prices2'in name:
180 res[id]['pi_list_prices2']= list_price2
181 if 'pi_next_better_price_qty'in name:
182 res[id]['pi_next_better_price_qty']= m_qty
183 if 'pi_best_price_on_qty'in name:
184 res[id]['pi_best_price_on_qty']= c_price3
185 if 'pi_last_customer_prices'in name:
186 res[id]['pi_last_customer_prices']= last_price
187 if 'pi_last_list_prices'in name:
188 res[id]['pi_last_list_prices']= last_list_price
189 if 'pi_qty_buyed'in name:
190 res[id]['pi_qty_buyed']= qty_last
191
192 else:
193 for id in ids:
194 res[id] = {}
195 if 'pi_customer_prices1' in name:
196 res[id]['pi_customer_prices1'] = 0.0
197 if 'pi_customer_prices2' in name:
198 res[id]['pi_customer_prices2'] = 0.0
199 if 'pi_list_prices1' in name:
200 res[id]['pi_list_prices1'] = 0.0
201 if 'pi_list_prices2'in name:
202 res[id]['pi_list_prices2']= 0.0
203 if 'pi_next_better_price_qty'in name:
204 res[id]['pi_next_better_price_qty']= 0.0
205 if 'pi_best_price_on_qty'in name:
206 res[id]['pi_best_price_on_qty']= 0.0
207 if 'pi_last_customer_prices'in name:
208 res[id]['pi_last_customer_prices']= 0.0
209 if 'pi_last_list_prices'in name:
210 res[id]['pi_last_list_prices']= 0.0
211 if 'pi_qty_buyed'in name:
212 res[id]['pi_qty_buyed']= 0.0
213 return res
214
215 _columns = {
216 'pi_quantity1': fields.float('Quantity1'),
217 'pi_quantity2': fields.float('Quantity2'),
218 'pi_pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
219 'pi_partner_id': fields.many2one('res.partner', 'Customer'),
220 'pi_customer_prices1': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices1'),
221 'pi_customer_prices2': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices2'),
222 'pi_list_prices1': fields.function(_get_all_values, method=True, type='float', string='List Prices',multi='pi_list_prices1'),
223 'pi_list_prices2': fields.function(_get_all_values, method=True, type='float', string='List Prices',multi='pi_list_prices2'),
224 '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'),
225 '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'),
226 'pi_last_customer_prices': fields.function(_get_all_values, method=True, type='float', string='Last Costomer Prices',multi='pi_last_customer_prices'),
227 'pi_last_list_prices': fields.function(_get_all_values, method=True, type='float', string='Last List Prices',multi='pi_last_list_prices'),
228 'pi_qty_buyed': fields.function(_get_all_values, method=True, type='float', string='Quantity Buyed',multi='pi_qty_buyed'),
229 }
230 _defaults = {
231 'pi_quantity1': lambda *a: 1.0,
232 'pi_quantity2': lambda *a: 5.0,
233 }
234product_product()
235
113236
=== modified file 'product_price_information/product_price_info_view.xml'
--- product_price_information/product_price_info_view.xml 2010-05-20 14:03:55 +0000
+++ product_price_information/product_price_info_view.xml 2010-06-22 14:09:30 +0000
@@ -1,9 +1,7 @@
1<?xml version="1.0" ?>1<?xml version="1.0" ?>
2<openerp>2<openerp>
3 <data>3 <data>
44 <!-- Adding shop price field on sale order line form below Unit Price -->
5<!-- Adding shop price field on sale order line form below Unit Price -->
6
7 <record model="ir.ui.view" id="view_sale_order_line_tree_direct_delivery">5 <record model="ir.ui.view" id="view_sale_order_line_tree_direct_delivery">
8 <field name="name">sale.order.form2</field>6 <field name="name">sale.order.form2</field>
9 <field name="model">sale.order</field>7 <field name="model">sale.order</field>
@@ -15,7 +13,7 @@
15 </xpath>13 </xpath>
16 </field>14 </field>
17 </record>15 </record>
18 16
19 <record model="ir.ui.view" id="product_tax_include_tree">17 <record model="ir.ui.view" id="product_tax_include_tree">
20 <field name="name">product.tax.include.tree</field>18 <field name="name">product.tax.include.tree</field>
21 <field name="model">product.product</field>19 <field name="model">product.product</field>
@@ -27,19 +25,58 @@
27 </field>25 </field>
28 </field>26 </field>
29 </record>27 </record>
30 28
31 <record id="view_partner_property_form" model="ir.ui.view">29 <record id="view_partner_property_form" model="ir.ui.view">
32 <field name="name">sale.shop.property.form.inherit</field>30 <field name="name">sale.shop.property.form.inherit</field>
33 <field name="model">sale.shop</field>31 <field name="model">sale.shop</field>
34 <field name="type">form</field>32 <field name="type">form</field>
35 <field name="inherit_id" ref="sale.view_shop_form"/>33 <field name="inherit_id" ref="sale.view_shop_form"/>
36 <field name="arch" type="xml">34 <field name="arch" type="xml">
37 <field name="project_id" position="after">35 <field name="project_id" position="after">
38 <field name="price_type"/>36 <field name="price_type"/>
39 </field>37 </field>
40 </field>38 </field>
41 </record>39 </record>
42 40
41 <!--product.product inherit view -->
42 <record id="product_product_price_information_inherit" model="ir.ui.view">
43 <field name="name">product.product.price.information.inherit</field>
44 <field name="model">product.product</field>
45 <field name="type">form</field>
46 <field name="inherit_id" ref="product.product_normal_form_view"/>
47 <field name="arch" type="xml">
48 <notebook colspan="4" position="inside">
49 <page string='Price Information'>
50 <field name="pi_partner_id"/>
51 <field name="pi_pricelist_id"/>
52 <field name="pi_quantity1"/>
53 <field name="pi_quantity2"/>
54 <newline/>
55 <group col="6" colspan="4">
56 <group col="4" colspan="3">
57 <separator string="Prices of Product" colspan="2"/>
58 <newline/>
59 <field name="pi_customer_prices1"/>
60 <field name="pi_customer_prices2" nolabel="1"/>
61 <field name="pi_list_prices1"/>
62 <field name="pi_list_prices2" nolabel="1"/>
63 <field name="pi_next_better_price_qty"/>
64 <newline/>
65 <field name="pi_best_price_on_qty"/>
66 </group>
67 <group col="3" colspan="3">
68 <separator string="Price on Last Sale" colspan="2"/>
69 <newline/>
70 <field name="pi_last_customer_prices"/>
71 <field name="pi_last_list_prices"/>
72 <field name="pi_qty_buyed"/>
73 </group>
74 </group>
75 </page>
76 </notebook>
77 </field>
78 </record>
79
43 <record id="view_config_price_policy" model="ir.ui.view">80 <record id="view_config_price_policy" model="ir.ui.view">
44 <field name="name">Price Method for Sale Order Shop</field>81 <field name="name">Price Method for Sale Order Shop</field>
45 <field name="model">sale.shop.price.method</field>82 <field name="model">sale.shop.price.method</field>
@@ -55,7 +92,7 @@
55 </form>92 </form>
56 </field>93 </field>
57 </record>94 </record>
58 95
59 <record id="action_config_price_policy" model="ir.actions.act_window">96 <record id="action_config_price_policy" model="ir.actions.act_window">
60 <field name="name">Price Method for Sale Order Shop</field>97 <field name="name">Price Method for Sale Order Shop</field>
61 <field name="type">ir.actions.act_window</field>98 <field name="type">ir.actions.act_window</field>
@@ -64,12 +101,12 @@
64 <field name="view_mode">form</field>101 <field name="view_mode">form</field>
65 <field name="target">new</field>102 <field name="target">new</field>
66 </record>103 </record>
67 104
68 <record id="config_wizard_step_shop_price_policy" model="ir.actions.todo">105 <record id="config_wizard_step_shop_price_policy" model="ir.actions.todo">
69 <field name="name">Shop Price</field>106 <field name="name">Shop Price</field>
70 <field name="note">This Configuration step use to set default price type for shop.</field>107 <field name="note">This Configuration step use to set default price type for shop.</field>
71 <field name="action_id" ref="action_config_price_policy"/>108 <field name="action_id" ref="action_config_price_policy"/>
72 </record>109 </record>
73 110
74 </data>111 </data>
75</openerp>112</openerp>
76113
=== modified file 'product_price_information/wizard/sale_prize_information_view.xml'
--- product_price_information/wizard/sale_prize_information_view.xml 2010-06-09 10:37:58 +0000
+++ product_price_information/wizard/sale_prize_information_view.xml 2010-06-22 14:09:30 +0000
@@ -6,46 +6,46 @@
6 <field name="model">sale.prize.information</field>6 <field name="model">sale.prize.information</field>
7 <field name="type">form</field>7 <field name="type">form</field>
8 <field name="arch" type="xml">8 <field name="arch" type="xml">
9 <form string="Sale Prize Information">9 <form string="Sale Prize Information">
10 <group col="6" colspan="4">10 <group col="6" colspan="4">
11 <group col="2" colspan="3">11 <group col="2" colspan="3">
12 <field name="partner_id"/>12 <field name="partner_id"/>
13 <field name="product_id"/>13 <field name="product_id"/>
14 <separator string="Prices of Product"/>14 <separator string="Prices of Product"/>
15 <newline/>15 <newline/>
16 <group col="4" colspan="2">16 <group col="4" colspan="2">
17 <field name="customer_prices1"/>17 <field name="customer_prices1"/>
18 <field name="customer_prices2" string=""/>18 <field name="customer_prices2" nolabel="1"/>
19 <field name="list_prices1"/>19 <field name="list_prices1"/>
20 <field name="list_prices2" string=""/>20 <field name="list_prices2" nolabel="1"/>
21 </group>
22 <field name="next_better_price_qty"/>
23 <field name="best_price_on_qty"/>
24 <newline/>
25 </group>
26 <group col="2" colspan="3">
27 <field name="pricelist_id"/>
28 <group col="4" colspan="2">
29 <field name="quantity1"/>
30 <field name="quantity2"/>
31 </group>
32 <separator string="Price on Last Sale"/>
33 <newline/>
34 <field name="last_customer_prices"/>
35 <field name="last_list_prices"/>
36 <field name="qty_buyed"/>
21 </group>37 </group>
22 <field name="next_better_price_qty"/>38 </group>
23 <field name="best_price_on_qty"/>39 <group col="2" colspan="4">
24 <newline/>40 <button icon="gtk-cancel" special="cancel" string="Cancel" />
25 </group>41 <button icon="gtk-ok" string="Calculate" name="set_default" type="object"/>
26 <group col="2" colspan="3">42 </group>
27 <field name="pricelist_id"/>43 </form>
28 <group col="4" colspan="2">
29 <field name="quantity1"/>
30 <field name="quantity2"/>
31 </group>
32 <separator string="Price on Last Sale"/>
33 <newline/>
34 <field name="last_customer_prices"/>
35 <field name="last_list_prices"/>
36 <field name="qty_buyed"/>
37 </group>
38 </group>
39 <group col="2" colspan="4">
40 <button icon='gtk-cancel' special="cancel" string="Cancel" />
41 <button icon="gtk-ok" string="Calculate" name="set_default" type="object" />
42 </group>
43 </form>
44 </field>44 </field>
45 </record>45 </record>
4646
47 <record id="action_sale_prize_information" model="ir.actions.act_window">47 <record id="action_sale_prize_information" model="ir.actions.act_window">
48 <field name="name">Sale Prize Information</field>48 <field name="name">Sale Price Information</field>
49 <field name="type">ir.actions.act_window</field>49 <field name="type">ir.actions.act_window</field>
50 <field name="res_model">sale.prize.information</field>50 <field name="res_model">sale.prize.information</field>
51 <field name="view_type">form</field>51 <field name="view_type">form</field>

Subscribers

People subscribed via source and target branches