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
##############################################################################
25
from report import report_sxw
28
class print_cheque(report_sxw.rml_parse):
29
def __init__(self, cr, uid, name, context):
30
super(print_cheque, self).__init__(cr, uid, name, context)
31
self.localcontext.update({
34
'date_sp': text.date_sp,
35
'moneyfmt': text.moneyfmt,
36
'total_debit': self._total_debit,
37
'total_credit': self._total_credit,
38
'get_cheques': self._get_cheques,
41
def _get_cheques(self, obj, data):
42
chk_obj = self.pool.get('payment.cheque')
44
for cheque in data['cheque']:
45
cheque_id = cheque[2] and chk_obj.browse(self.cr, self.uid, cheque[1])
50
def _total_debit(self,move_id):
51
self.cr.execute("SELECT SUM(credit) " \
52
"FROM account_move_line AS line " \
53
"WHERE (line.move_id = %s) ",
55
total = self.cr.fetchone()[0]
58
def _total_credit(self,move_id, obj=False):
59
self.cr.execute("SELECT SUM(debit) " \
60
"FROM account_move_line AS line " \
61
"WHERE (line.move_id = %s) ",
63
total = self.cr.fetchone()[0]
64
chk_obj = self.pool.get('payment.cheque')
65
chk_obj.write(self.cr, self.uid, [obj.id],{'state': 'printed'})
68
report_sxw.report_sxw('report.payment.cheque.entry', 'payment.cheque',
69
'addons/bias_payment/report/print_entry.rml', parser=print_cheque, header=False)
71
report_sxw.report_sxw('report.payment.cheque.print_from_wizard_a', 'payment.cheque',
72
'addons/bias_payment/report/print_cheque_from_wizard_a.rml', parser=print_cheque, header=False)