1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 from osv import fields, osv
24 from tools import config
28 class product_product(osv.osv):
29 _name = 'product.product'
30 _inherit = 'product.product'
32 def _pricelist_calculate(self, cr, uid, ids, name, arg, context=None):
34 pricelist_obj=self.pool.get('product.pricelist')
35 if name=='pricelist_purchase':
36 pricelist_ids=pricelist_obj.search(cr,uid,[('type','=','purchase')])
38 pricelist_ids=pricelist_obj.search(cr,uid,[('type','=','sale')])
39 pricelist_browse=pricelist_obj.browse(cr,uid,pricelist_ids)
40 for product in self.browse(cr, uid, ids, context):
41 result[product.id] = ""
42 for pricelist in pricelist_browse:
43 for version in pricelist.version_id:
44 for items in version.items_id:
45 qty = items.min_quantity
47 prices = pricelist_obj.price_get(cr, uid, [pricelist.id], product.id, qty, partner=None, context=None)
48 price = prices.get(pricelist.id) or 0.0
51 result[product.id] += "%s (%.2f) : %.2f\n" % (pricelist.name, qty or 0.0, price)
57 'pricelist_sale':fields.function(
60 string='Sale Pricelists',
63 'pricelist_purchase':fields.function(
66 string='Purchase Pricelists',
72 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: