~openbias/bias-trunk/bias-public-trunk

« back to all changes in this revision

Viewing changes to bias_payment/report/print_entry.py

  • Committer: Jose Patricio
  • Date: 2011-10-19 03:16:40 UTC
  • Revision ID: josepato@bias.com.mx-20111019031640-05zd7r5lxwx084qu
el push inicial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution   
 
5
#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 
6
#    $Id$
 
7
#
 
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.
 
12
#
 
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.
 
17
#
 
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/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
import time
 
24
import pooler
 
25
from report import report_sxw
 
26
import text
 
27
 
 
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({
 
32
                    'time': time,
 
33
                    'texto': text.text,
 
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,
 
39
                })
 
40
 
 
41
        def _get_cheques(self, obj, data):
 
42
                chk_obj = self.pool.get('payment.cheque')
 
43
                res = []
 
44
                for cheque in data['cheque']:
 
45
                        cheque_id = cheque[2] and chk_obj.browse(self.cr, self.uid, cheque[1])
 
46
                        if cheque_id:
 
47
                                res.append(cheque_id)
 
48
                return res
 
49
 
 
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) ",
 
54
                                        (move_id.id,))
 
55
                total = self.cr.fetchone()[0]
 
56
                return total
 
57
 
 
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) ",
 
62
                                        (move_id.id,))
 
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'})
 
66
                return total
 
67
 
 
68
report_sxw.report_sxw('report.payment.cheque.entry', 'payment.cheque',
 
69
        'addons/bias_payment/report/print_entry.rml', parser=print_cheque, header=False)
 
70
 
 
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)
 
73
 
 
74
 
 
75