1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5
# Fabien Pinckaers <fp@tiny.Be>
7
# WARNING: This program as such is intended to be used by professional
8
# programmers who take the whole responsability of assessing all potential
9
# consequences resulting from its eventual inadequacies and bugs
10
# End users who are looking for a ready-to-use solution with commercial
11
# garantees and support are strongly adviced to contract a Free Software
14
# This program is Free Software; you can redistribute it and/or
15
# modify it under the terms of the GNU General Public License
16
# as published by the Free Software Foundation; either version 2
17
# of the License, or (at your option) any later version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
##############################################################################
31
from osv import fields,osv,orm
33
class delivery_grid(osv.osv):
34
_name = "delivery.grid"
35
_inherit = "delivery.grid"
37
def get_price(self, cr, uid, id, order, dt, context):
39
This is not very clean because the function has to check the type of order.
40
It could be improve by changing the signature of the method and by passing a dict in place of a browse record.
46
for line in order.order_line:
47
if not line.product_id:
51
if order._table_name == "sale.order":
52
qty = line.product_uom_qty
54
qty = line.product_qty
56
total += line.price_subtotal or 0.0
57
weight += (line.product_id.weight or 0.0) * qty
58
volume += (line.product_id.volume or 0.0) * qty
60
return self.get_price_from_picking(cr, uid, id, total,weight, volume, context)
62
def get_price_from_picking(self, cr, uid, id, total, weight, volume, context={}):
63
grid = self.browse(cr, uid, id, context)
68
for line in grid.line_ids:
69
price_dict = {'price': total, 'volume':volume, 'weight': weight, 'wv':volume*weight}
70
test = eval(line.type+line.operator+str(line.max_value), price_dict)
72
if context.has_key('object') and context['object']=='purchase':
73
price = line.standard_price
75
price = line.list_price
76
if line.price_type=='variable':
77
price *= price_dict[line.variable_factor]
81
raise except_osv('No price avaible !', 'No line matched this order in the choosed delivery grids !')
85
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: