~luc-demeyer/openobject-addons/7.0-account_financial_report_webkit-fixes

« back to all changes in this revision

Viewing changes to account_financial_report/model/account_financial_report.py

  • Committer: Humberto Arocha
  • Date: 2012-08-15 06:37:35 UTC
  • mfrom: (18.1.49 merging_parsers_hbto)
  • Revision ID: humbertoarocha@gmail.com-20120815063735-v502b9gsmzj06xs8

[MERGE] Se mezcla nueva iteracion del asistente
de reportes finacieros, que cuenta con:
- Balance General
- Estado de Resultado,
- Mayor Analitico,
Adicionalmente,
Tanto el Balance General como el Estado de Resultados
se pueden Pedir en cinco sabores:
- Una Columna (Saldo al Final del Periodo)
- Dos Columnas (Debito y Credito del Periodo pedido)
- Cuatro Columnas (Inicial, Debito, Credito, Saldo Final)
- Cinco Columnas (Inicial, Debito, Credito, Cambio en Periodo, Saldo Final)
- Trece Columnas (12 Meses, Saldo al Final)
- Cuartos (4 Cuartos y Saldo al Final)

Todos los reportes ahora usan un solo parser,
que centraliza y minimiza el proceso de correciones,
y optimiza el proceso de mejoras.

Agrega tambien esta mejora una seccion para guardar
Plantillas que se pueden reutilizar,

Asi como la generacion de los reportes expresados
en otras monedas.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
 
5
#    All Rights Reserved
 
6
###############Credits######################################################
 
7
#    Coded by:   Humberto Arocha humberto@openerp.com.ve
 
8
#                Angelica Barrios angelicaisabelb@gmail.com
 
9
#               Jordi Esteve <jesteve@zikzakmedia.com>
 
10
#               Javier Duran <javieredm@gmail.com>
 
11
#    Planified by: Humberto Arocha
 
12
#    Finance by: LUBCAN COL S.A.S http://www.lubcancol.com
 
13
#    Audited by: Humberto Arocha humberto@openerp.com.ve
 
14
#############################################################################
 
15
#    This program is free software: you can redistribute it and/or modify
 
16
#    it under the terms of the GNU General Public License as published by
 
17
#    the Free Software Foundation, either version 3 of the License, or
 
18
#    (at your option) any later version.
 
19
#
 
20
#    This program is distributed in the hope that it will be useful,
 
21
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
#    GNU General Public License for more details.
 
24
#
 
25
#    You should have received a copy of the GNU General Public License
 
26
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
27
##############################################################################
 
28
 
 
29
from osv import osv,fields
 
30
import pooler
 
31
import time
 
32
from tools.translate import _
 
33
 
 
34
class account_financial_report(osv.osv):
 
35
    _name = "afr"
 
36
 
 
37
    _columns = {
 
38
        'name': fields.char('Name', size= 128, required=True),
 
39
        'company_id': fields.many2one('res.company','Company',required=True),
 
40
        'currency_id': fields.many2one('res.currency', 'Currency', help="Currency at which this report will be expressed. If not selected will be used the one set in the company"),
 
41
        'inf_type': fields.selection([('BS','Balance Sheet'),('IS','Income Statement')],'Type',required=True),
 
42
        'columns': fields.selection([('one','End. Balance'),('two','Debit | Credit'), ('four','Initial | Debit | Credit | YTD'), ('five','Initial | Debit | Credit | Period | YTD'),('qtr',"4 QTR's | YTD"), ('thirteen','12 Months | YTD')],'Columns',required=True),
 
43
        'display_account': fields.selection([('all','All Accounts'),('bal', 'With Balance'),('mov','With movements'),('bal_mov','With Balance / Movements')],'Display accounts'),
 
44
        'display_account_level': fields.integer('Up to level',help='Display accounts up to this level (0 to show all)'),
 
45
        'account_ids': fields.many2many ('account.account','afr_account_rel','afr_id','account_id','Root accounts',required=True),
 
46
        'fiscalyear_id': fields.many2one('account.fiscalyear','Fiscal year',help='Fiscal Year for this report',required=True),
 
47
        'period_ids': fields.many2many('account.period','afr_period_rel','afr_id','period_id','Periods',help='All periods in the fiscal year if empty'),
 
48
        
 
49
        'analytic_ledger': fields.boolean('Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"),
 
50
        
 
51
        'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
 
52
        'lab_str': fields.char('Description', help='Description for the Summary', size= 128),
 
53
        
 
54
        #~ Deprecated fields
 
55
        'filter': fields.selection([('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],'Date/Period Filter'),
 
56
        'date_to': fields.date('End date'),
 
57
        'date_from': fields.date('Start date'),
 
58
    }
 
59
    
 
60
    _defaults = {
 
61
        'display_account_level': lambda *a: 0,
 
62
        'inf_type': lambda *a:'BS',
 
63
        'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
 
64
        'fiscalyear_id': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
 
65
        'display_account': lambda *a:'bal_mov',
 
66
        'columns': lambda *a:'five',
 
67
        
 
68
        'date_from': lambda *a: time.strftime('%Y-%m-%d'),
 
69
        'date_to': lambda *a: time.strftime('%Y-%m-%d'),
 
70
        'filter': lambda *a:'byperiod',
 
71
    }
 
72
    
 
73
    def copy(self, cr, uid, id, defaults, context=None):
 
74
        if context is None:
 
75
            context = {}
 
76
        previous_name = self.browse(cr, uid, id, context=context).name
 
77
        new_name = _('Copy of %s')%previous_name
 
78
        lst = self.search(cr, uid, [('name','like',new_name)], context=context)
 
79
        if lst:
 
80
            new_name = '%s (%s)' % (new_name, len(lst)+1)
 
81
        defaults['name'] = new_name
 
82
        return super(account_financial_report,self).copy(cr, uid, id, defaults, context=context)
 
83
 
 
84
    def onchange_inf_type(self,cr,uid,ids,inf_type,context=None):
 
85
        if context is None:
 
86
            context = {}
 
87
        res = {'value':{}}
 
88
        
 
89
        if inf_type != 'BS':
 
90
            res['value'].update({'analytic_ledger':False})
 
91
        
 
92
        return res
 
93
 
 
94
    def onchange_columns(self,cr,uid,ids,columns,fiscalyear_id,period_ids,context=None):
 
95
        if context is None:
 
96
            context = {}
 
97
        res = {'value':{}}
 
98
        
 
99
        if columns != 'four':
 
100
            res['value'].update({'analytic_ledger':False})
 
101
        
 
102
        if columns in ('qtr', 'thirteen'):
 
103
            p_obj = self.pool.get("account.period")
 
104
            period_ids = p_obj.search(cr,uid,[('fiscalyear_id','=',fiscalyear_id),('special','=',False)],context=context)
 
105
            res['value'].update({'period_ids':period_ids})
 
106
        else:
 
107
            res['value'].update({'period_ids':[]})
 
108
        return res
 
109
        
 
110
    def onchange_analytic_ledger(self,cr,uid,ids,company_id,analytic_ledger,context=None):
 
111
        if context is None:
 
112
            context = {}
 
113
        context['company_id']=company_id
 
114
        res = {'value':{}}
 
115
        cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
 
116
        res['value'].update({'currency_id':cur_id})
 
117
        return res
 
118
        
 
119
    def onchange_company_id(self,cr,uid,ids,company_id,context=None):
 
120
        if context is None:
 
121
            context = {}
 
122
        context['company_id']=company_id
 
123
        res = {'value':{}}
 
124
        cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
 
125
        fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context)
 
126
        res['value'].update({'fiscalyear_id':fy_id})
 
127
        res['value'].update({'currency_id':cur_id})
 
128
        res['value'].update({'account_ids':[]})
 
129
        res['value'].update({'period_ids':[]})
 
130
        return res
 
131
 
 
132
 
 
133
account_financial_report()