1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
25 from report import report_sxw
27 class payment_order(report_sxw.rml_parse):
29 def __init__(self, cr, uid, name, context=None):
30 super(payment_order, self).__init__(cr, uid, name, context=context)
31 self.localcontext.update( {
33 'get_invoice_name': self._get_invoice_name,
34 'get_company_currency': self._get_company_currency,
35 'get_company_currency_symbol': self._get_company_currency_symbol,
36 'get_amount_total_in_currency': self._get_amount_total_in_currency,
37 'get_amount_total': self._get_amount_total,
38 'get_account_name': self._get_account_name,
41 def _get_invoice_name(self, invoice_id):
43 pool = pooler.get_pool(self.cr.dbname)
44 value_name = pool.get('account.invoice').name_get(self.cr, self.uid, [invoice_id])
46 return value_name[0][1]
49 def _get_amount_total_in_currency(self, payment):
52 currency_cmp = payment.line_ids[0].currency.id
55 for line in payment.line_ids:
56 if currency_cmp == line.currency.id:
57 total += line.amount_currency
62 def _get_amount_total(self, payment):
64 if not payment.line_ids:
66 for line in payment.line_ids:
70 def _get_company_currency(self):
71 pool = pooler.get_pool(self.cr.dbname)
72 user = pool.get('res.users').browse(self.cr, self.uid, self.uid)
73 return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False
75 def _get_company_currency_symbol(self):
76 pool = pooler.get_pool(self.cr.dbname)
77 user = pool.get('res.users').browse(self.cr, self.uid, self.uid)
78 return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False
80 def _get_account_name(self,bank_id):
82 pool = pooler.get_pool(self.cr.dbname)
83 value_name = pool.get('res.partner.bank').name_get(self.cr, self.uid, [bank_id])
85 return value_name[0][1]
88 report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external")
90 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: