21
21
##############################################################################
22
22
from osv import fields, osv
23
23
from tools import config
25
25
class sale_order_line(osv.osv):
26
26
_inherit = "sale.order.line"
29
29
'sale_price_unit_tax': fields.float('Sale price W/O taxes'),
32
32
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
33
33
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
34
34
lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False):
36
36
tax_obj = self.pool.get('account.tax')
38
38
result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty,
39
39
uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging, fiscal_position, flag)
107
107
'type': 'ir.actions.act_window',
111
sale_shop_price_method_policy()
b'\\ No newline at end of file'
111
sale_shop_price_method_policy()
114
class product_product(osv.osv):
115
_name = "product.product"
116
_inherit = "product.product"
117
_description = "Product"
119
def _get_all_values(self, cr, uid, ids, name, arg, context={}):
122
product_obj = self.pool.get('product.product')
123
obj2 = self.pool.get('product.pricelist.item')
124
obj = self.pool.get('product.pricelist')
125
obj3 = self.pool.get('sale.order.line')
126
for line in product_obj.browse(cr, uid, product, context=context):
127
partner = line.pi_partner_id.id
128
pricelist = line.pi_pricelist_id.id
129
qty1 = line.pi_quantity1
130
qty2 = line.pi_quantity2
131
if pricelist != False:
132
val1 = obj.price_get(cr, uid, [pricelist], line.id, qty1, partner)
133
for key,values in val1.items():
135
val2 = obj.price_get(cr, uid, [pricelist], line.id, qty2, partner)
136
for key,values in val2.items():
138
item_line = obj2.search(cr,uid,[])
140
for line2 in obj2.browse(cr, uid, item_line, context=context):
141
if line.id == line2.product_id.id:
142
list.append(line.min_quantity)
147
val3 = obj.price_get(cr, uid, [pricelist], line.id, m_qty, partner)
148
for key,values in val3.items():
150
list_price = product_obj.browse(cr, uid, line.id).standard_price
151
list_price1 = list_price * qty1
152
list_price2 = list_price * qty2
153
read_id = obj3.search(cr,uid,[('product_id','=',line.id)])
157
last_list_price = 0.0
159
last_id = max(read_id)
160
last_brw = obj3.browse(cr,uid,[last_id],context=context)
162
product2 = rec.product_id.id
163
if line.id == product2:
164
last_price = rec.price_unit
165
qty_last = rec.product_uom_qty
166
val_last = obj.price_get(cr, uid,[pricelist], line.id, qty_last)
167
for key,values in val_last.items():
168
last_list_price = values
172
if 'pi_customer_prices1' in name:
173
res[id]['pi_customer_prices1'] = c_price1
174
if 'pi_customer_prices2' in name:
175
res[id]['pi_customer_prices2'] = c_price2
176
if 'pi_list_prices1' in name:
177
res[id]['pi_list_prices1'] = list_price1
178
if 'pi_list_prices2'in name:
179
res[id]['pi_list_prices2']= list_price2
180
if 'pi_next_better_price_qty'in name:
181
res[id]['pi_next_better_price_qty']= m_qty
182
if 'pi_best_price_on_qty'in name:
183
res[id]['pi_best_price_on_qty']= c_price3
184
if 'pi_last_customer_prices'in name:
185
res[id]['pi_last_customer_prices']= last_price
186
if 'pi_last_list_prices'in name:
187
res[id]['pi_last_list_prices']= last_list_price
188
if 'pi_qty_buyed'in name:
189
res[id]['pi_qty_buyed']= qty_last
194
if 'pi_customer_prices1' in name:
195
res[id]['pi_customer_prices1'] = 0.0
196
if 'pi_customer_prices2' in name:
197
res[id]['pi_customer_prices2'] = 0.0
198
if 'pi_list_prices1' in name:
199
res[id]['pi_list_prices1'] = 0.0
200
if 'pi_list_prices2'in name:
201
res[id]['pi_list_prices2']= 0.0
202
if 'pi_next_better_price_qty'in name:
203
res[id]['pi_next_better_price_qty']= 0.0
204
if 'pi_best_price_on_qty'in name:
205
res[id]['pi_best_price_on_qty']= 0.0
206
if 'pi_last_customer_prices'in name:
207
res[id]['pi_last_customer_prices']= 0.0
208
if 'pi_last_list_prices'in name:
209
res[id]['pi_last_list_prices']= 0.0
210
if 'pi_qty_buyed'in name:
211
res[id]['pi_qty_buyed']= 0.0
215
'pi_quantity1': fields.float('Quantity1'),
216
'pi_quantity2': fields.float('Quantity2'),
217
'pi_pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
218
'pi_partner_id': fields.many2one('res.partner', 'Customer'),
219
'pi_customer_prices1': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices1'),
220
'pi_customer_prices2': fields.function(_get_all_values, method=True, type='float', string='Costomer Prices',multi='pi_customer_prices2'),
221
'pi_list_prices1': fields.function(_get_all_values, method=True, type='float', string='List Prices',multi='pi_list_prices1'),
222
'pi_list_prices2': fields.function(_get_all_values, method=True, type='float', string='List Prices',multi='pi_list_prices2'),
223
'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'),
224
'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'),
225
'pi_last_customer_prices': fields.function(_get_all_values, method=True, type='float', string='Last Costomer Prices',multi='pi_last_customer_prices'),
226
'pi_last_list_prices': fields.function(_get_all_values, method=True, type='float', string='Last List Prices',multi='pi_last_list_prices'),
227
'pi_qty_buyed': fields.function(_get_all_values, method=True, type='float', string='Quantity Buyed',multi='pi_qty_buyed'),
230
'pi_quantity1': lambda *a: 1.0,
231
'pi_quantity2': lambda *a: 5.0,