2 # -*- coding: utf-8 -*-
3 ##############################################################################
5 # OpenERP, Open Source Management Solution
6 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as
10 # published by the Free Software Foundation, either version 3 of the
11 # License, or (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 Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
25 from report import report_sxw
28 def _get_country(record):
29 if record.partner_id \
30 and record.partner_id.address \
31 and record.partner_id.address[0].country_id:
32 return record.partner_id.address[0].country_id.code
36 def _record_to_report_line(record):
37 return {'date': record.date,
39 'acode': record.account_id.code,
41 'debit': record.debit,
42 'credit': record.credit,
43 'pname': record.partner_id and record.partner_id.name or '',
44 'country': _get_country(record)
47 class account_tax_code_report(rml_parse.rml_parse):
48 def __init__(self, cr, uid, name, context):
49 super(account_tax_code_report, self).__init__(cr, uid, name, context=context)
50 self.localcontext.update({
52 'get_line':self.get_line,
55 def get_line(self, obj):
56 line_ids = self.pool.get('account.move.line').search(self.cr, self.uid, [('tax_code_id','=',obj.id)])
57 if not line_ids: return []
59 return map(_record_to_report_line,
60 self.pool.get('account.move.line')\
61 .browse(self.cr, self.uid, line_ids))
63 report_sxw.report_sxw('report.account.tax.code.entries', 'account.tax.code',
64 'addons/account/report/account_tax_code.rml', parser=account_tax_code_report, header="internal")
66 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: