~avanzosc/openerp-spain/6.1

« back to all changes in this revision

Viewing changes to account_balance_reporting/wizard/wizard_print.py

  • Committer: Pedro M. Baeza
  • Date: 2014-01-10 10:36:59 UTC
  • Revision ID: pedro.baeza@serviciosbaeza.com-20140110103659-g2iyd3c1gj3c3dg3
[ADD] account_balance_reporting: Motor de informes de cuentas anuales. Incluye las siguientes mejoras sobre la anterior versión:
- Añadida la opción de que si no se pone ninguna fórmula en el ejercicio fiscal 2, se utiliza la fórmula del ejercicio fiscal 1. De esta forma, se reduce la cantidad de datos (ya que normalmente la fórmula es la misma), se aligera la pantalla de datos, y se hace más intuitivo (teniendo que tocar sólo en un sitio en lugar de en dos cuando se modifica alguna fórmula).
- Añadida la posibilidad de parsear espacios, que hasta el momento no se admitían, lo cual provocaba también posibles fallos de cálculo que no eran reportados al usuario (no se mostraba ningún error, pero la línea se quedaba con valor 0), provocando confusión.
- Corregido cálculo del signo para cuentas credit y debit. Tal como estaba, la expresión -debit(xxx) o -credit(xxx) sumaba el debe o el haber, nunca restaba.
- Corregido cálculo de la expresión debit, que añadía la suma de los saldos deudores en positivo en lugar de en negativo, que es como saldría si se obtiene el saldo de una cuenta que sólo tiene entradas en el debe.
- Corregida utilización de paréntesis para códigos. En el caso del cálculo con códigos, siempre se invertía el signo, independientemente del modo de informe.
[IMP] l10n_es_account_balance_report:
- Se han actualizado las plantillas para tener sólo la fórmula del ejercicio fiscal 1, ya que en todos los casos la fórmula del ejercicio fiscal 2 era la misma.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# -*- encoding: utf-8 -*-
 
3
##############################################################################
 
4
#
 
5
#    OpenERP - Account balance reporting engine
 
6
#    Copyright (C) 2009 Pexego Sistemas Informáticos. All Rights Reserved
 
7
#    $Id$
 
8
#
 
9
#    This program is free software: you can redistribute it and/or modify
 
10
#    it under the terms of the GNU General Public License as published by
 
11
#    the Free Software Foundation, either version 3 of the License, or
 
12
#    (at your option) any later version.
 
13
#
 
14
#    This program is distributed in the hope that it will be useful,
 
15
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
#    GNU General Public License for more details.
 
18
#
 
19
#    You should have received a copy of the GNU General Public License
 
20
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
#
 
22
##############################################################################
 
23
 
 
24
"""
 
25
Account balance report print wizard
 
26
"""
 
27
__author__ = "Borja López Soilán (Pexego)"
 
28
 
 
29
 
 
30
from osv import fields, osv
 
31
import pooler
 
32
 
 
33
 
 
34
class print_wizard(osv.osv_memory):
 
35
    _name='account.balance.reporting.print.wizard'
 
36
    
 
37
    def _get_current_report_id(self, cr, uid, ctx):   
 
38
        rpt_facade = pooler.get_pool(cr.dbname).get('account.balance.reporting')
 
39
        report_id = None
 
40
        if ctx.get('active_model') == 'account.balance.reporting' and ctx.get('active_ids') and ctx.get('active_ids')[0]:
 
41
            report_id = ctx.get('active_ids')[0]
 
42
            report_ids = rpt_facade.search(cr, uid, [('id', '=', report_id)])
 
43
            report_id = report_ids and report_ids[0] or None
 
44
        return report_id
 
45
 
 
46
    def _get_current_report_xml_id(self, cr, uid, ctx):
 
47
        report_id = self._get_current_report_id(cr, uid, ctx)
 
48
        rpt_facade = pooler.get_pool(cr.dbname).get('account.balance.reporting')
 
49
        report = rpt_facade.browse(cr, uid, [report_id])[0]
 
50
        report_xml_id = None
 
51
        if report.template_id and report.template_id.report_xml_id:
 
52
            report_xml_id = report.template_id.report_xml_id.id
 
53
        return report_xml_id
 
54
 
 
55
    def print_report(self, cr, uid, ids, context=None):
 
56
        data = self.read(cr,uid,ids)[-1]
 
57
        #rpt_facade_lines = pooler.get_pool(cr.dbname).get('account.balance.reporting.line')
 
58
        #var = data.get('report_id') and data['report_id'][0] or None
 
59
        #report_lines_ids = rpt_facade_lines.search(cr, uid, [('report_id', '=', var)])
 
60
        #print data
 
61
        #print str(data.get('report_id'))
 
62
        #print str(data['report_id'][0])
 
63
        datas ={
 
64
                'ids': [data.get('report_id') and data['report_id'][0] or None],
 
65
                'model':'account.balance.reporting',
 
66
                'form': data
 
67
                }
 
68
        rpt_facade = pooler.get_pool(cr.dbname).get('ir.actions.report.xml')
 
69
        report_xml = None
 
70
        if data.get('report_xml_id'):
 
71
            report_xml_id = data['report_xml_id']
 
72
            report_xml_ids = rpt_facade.search(cr, uid, [('id', '=', report_xml_id[0])])
 
73
            report_xml_id = report_xml_ids and report_xml_ids[0] or None
 
74
            if report_xml_id:
 
75
                report_xml = rpt_facade.browse(cr, uid, [report_xml_id])[0]
 
76
            if report_xml:
 
77
                return {
 
78
                    'type' : 'ir.actions.report.xml',
 
79
                    'report_name' : report_xml.report_name,
 
80
                    'datas' : datas #{'ids': [data.get('report_id') and data['report_id'][0] or None]},
 
81
                }
 
82
        return { 'type': 'ir.actions.act_window_close' }
 
83
        
 
84
    _columns = {
 
85
        'report_id' : fields.many2one('account.balance.reporting', "Report"),
 
86
        'report_xml_id': fields.many2one('ir.actions.report.xml', "Design"),
 
87
    }
 
88
    
 
89
    _defaults = {
 
90
        'report_id': _get_current_report_id,
 
91
        'report_xml_id': _get_current_report_xml_id
 
92
    }
 
93
 
 
94
print_wizard()
 
95