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 ##############################################################################
24 from report import report_sxw
26 class lot_overview_all(report_sxw.rml_parse):
27 def __init__(self, cr, uid, name, context):
28 super(lot_overview_all, self).__init__(cr, uid, name, context)
29 self.price_total = 0.0
30 self.localcontext.update({
32 'process':self.process,
33 'price_total': self._price_total,
36 def process(self,location_id):
38 location_obj = pooler.get_pool(self.cr.dbname).get('stock.location')
39 product_obj = pooler.get_pool(self.cr.dbname).get('product.product')
41 product_ids = product_obj.search(self.cr, self.uid, [])
43 products = product_obj.browse(self.cr,self.uid, product_ids)
46 for product in products:
47 products_by_uom.setdefault(product.uom_id.id, [])
48 products_by_uom[product.uom_id.id].append(product)
49 products_by_id.setdefault(product.id, [])
50 products_by_id[product.id] = product
55 for uom_id in products_by_uom.keys():
56 fnc = location_obj._product_get
57 qty = fnc(self.cr, self.uid, id, [x.id for x in products_by_uom[uom_id]])
58 for product_id in qty.keys():
59 if not qty[product_id]:
61 product = products_by_id[product_id]
62 value=(product.standard_price)*(qty[product_id])
63 self.price_total += value
67 'variants': product.variants or '',
68 'code': product.default_code,
69 'amount': str(qty[product_id]),
70 'uom': product.uom_id.name,
71 'price': str(product.standard_price),
78 def _price_total(self):
79 return str( self.price_total)
81 report_sxw.report_sxw('report.lot.stock.overview_all', 'stock.location', 'addons/stock/report/lot_overview_all.rml', parser=lot_overview_all)
84 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: