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

« back to all changes in this revision

Viewing changes to bias_fiscal_statements/report_bak/fiscal_statements.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 pooler
 
24
import time
 
25
import re
 
26
import rml_parse
 
27
import datetime
 
28
from report import report_sxw
 
29
import text
 
30
 
 
31
class fiscal_statements(rml_parse.rml_parse):
 
32
        def __init__(self, cr, uid, name, context):
 
33
                self.date_lst = []
 
34
                self.date_lst_string = ''
 
35
                super(fiscal_statements, self).__init__(cr, uid, name, context)
 
36
                self.localcontext.update( {
 
37
                        'time': time,
 
38
                        'comma_me': self.comma_me,
 
39
                        'get_company': self._get_company,
 
40
                        'get_title': self._get_title,
 
41
                        'get_date_end': self._get_date_end,
 
42
                        'lines': self._get_lines,
 
43
                        'get_information': self._get_information,
 
44
                })
 
45
 
 
46
        def comma_me(self,amount):
 
47
                if  type(amount) is float :
 
48
                        amount = str('%.2f'%amount)
 
49
                else :
 
50
                        amount = str(amount)
 
51
                if (amount == '0'):
 
52
                     return ' '
 
53
                orig = amount
 
54
                new = re.sub("^(-?\d+)(\d{3})", "\g<1>,\g<2>", amount)
 
55
                if orig == new:
 
56
                        return new
 
57
                else:
 
58
                        return self.comma_me(new)
 
59
 
 
60
        def set_context(self, objects, data, ids, report_type = None):
 
61
                self.fis_obj = self.pool.get('fiscal.statements')
 
62
                objects, new_ids = self.fis_obj._get_context(self.cr, self.uid, objects, data, ids, report_type = None)
 
63
                super(fiscal_statements, self).set_context(objects, data, new_ids, report_type)
 
64
 
 
65
        def _get_information(self, form):
 
66
                return self.fis_obj._get_information(self.cr, self.uid, form)
 
67
 
 
68
        def _get_company(self, form):
 
69
                self.fis_obj = self.pool.get('fiscal.statements')
 
70
                return self.fis_obj._get_company(self.cr, self.uid, form)
 
71
 
 
72
        def _get_title(self, form):
 
73
                return self.fis_obj._get_title(self.cr, self.uid, form)
 
74
 
 
75
        def _get_date_end(self, form):
 
76
                return self.fis_obj._get_date_end(self.cr, self.uid, form)
 
77
 
 
78
        def _get_lines(self, obj, data):
 
79
                return self.fis_obj._get_lines(self.cr, self.uid, obj, data)
 
80
 
 
81
report_sxw.report_sxw('report.fiscal_statements_balance', 'res.partner',
 
82
                'addons/bias_fiscal_statements/report/fiscal_statements_balance.rml',parser=fiscal_statements,
 
83
                header=False)
 
84
report_sxw.report_sxw('report.fiscal_statements_income', 'res.partner',
 
85
                'addons/bias_fiscal_statements/report/fiscal_statements_income.rml',parser=fiscal_statements,
 
86
                header=False)
 
87
 
 
88