1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
8 # WARNING: This program as such is intended to be used by professional
9 # programmers who take the whole responsability of assessing all potential
10 # consequences resulting from its eventual inadequacies and bugs
11 # End users who are looking for a ready-to-use solution with commercial
12 # garantees and support are strongly adviced to contract a Free Software
15 # This program is Free Software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 ##############################################################################
31 from report.interface import report_rml
32 from report.interface import toxml
36 class report_custom(report_rml):
38 def create_xml(self, cr, uid, ids, datas, context=None):
39 pool = pooler.get_pool(cr.dbname)
40 product_obj = pool.get('product.product')
41 location_obj = pool.get('stock.location')
43 products = product_obj.read(cr, uid, ids, ['name','uom_id'])
44 cr.execute('SELECT id FROM stock_location WHERE usage = %s',
46 location_ids = [ x[0] for x in cr.fetchall() ]
49 locs_name = dict(location_obj.name_get(cr, uid, location_ids))
50 for location_id in locs_name.keys():
51 locs_info[location_id] = location_obj._product_get(cr, uid,
54 xml = '<?xml version="1.0" ?><report>'
57 '<name>' + toxml(p['name']) + '</name>' \
58 '<unit>' + toxml(p['uom_id'][1]) + '</unit>' \
60 for loc_id in locs_info.keys():
61 if locs_info[loc_id].get(p['id']):
63 xml += '<loc_name>' + toxml(locs_name[loc_id]) \
65 xml += '<loc_qty>' + toxml(locs_info[loc_id].get(p['id'])) \
68 xml += '</locations>' \
71 return self.post_process_xml_data(cr, uid, xml, context)
73 report_custom('report.stock.product.location', 'stock.location', '',
74 'addons/stock/report/product_location.xsl')
77 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: