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 ##############################################################################
23 from openerp.report import report_sxw
24 from openerp.tools import amount_to_text_en
26 class report_voucher_print(report_sxw.rml_parse):
27 def __init__(self, cr, uid, name, context):
28 super(report_voucher_print, self).__init__(cr, uid, name, context)
29 self.localcontext.update({
31 'get_title': self.get_title,
32 'get_lines':self.get_lines,
33 'get_on_account':self.get_on_account,
34 'convert':self.convert
37 def convert(self, amount, cur):
38 amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur)
41 def get_lines(self, voucher):
43 if voucher.type in ('payment','receipt'):
44 type = voucher.line_ids and voucher.line_ids[0].type or False
45 for move in voucher.move_ids:
51 res['pname'] = move.partner_id.name
52 res['ref'] = 'Agst Ref'+" "+str(move.name)
53 res['aname'] = move.account_id.name
54 res['amount'] = amount
57 type = voucher.line_ids and voucher.line_ids[0].type or False
58 for move in voucher.move_ids:
64 res['pname'] = move.partner_id.name
65 res['ref'] = move.name
66 res['aname'] = move.account_id.name
67 res['amount'] = amount
71 def get_title(self, type):
74 title = type[0].swapcase() + type[1:] + " Voucher"
77 def get_on_account(self, voucher):
79 if voucher.type == 'receipt':
80 name = "Received cash from "+str(voucher.partner_id.name)
81 elif voucher.type == 'payment':
82 name = "Payment from "+str(voucher.partner_id.name)
83 elif voucher.type == 'sale':
84 name = "Sale to "+str(voucher.partner_id.name)
85 elif voucher.type == 'purchase':
86 name = "Purchase from "+str(voucher.partner_id.name)
89 report_sxw.report_sxw(
90 'report.voucher.print',
92 'addons/account_voucher/report/account_voucher_print.rml',
93 parser=report_voucher_print,header="external"
96 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: