1
# -*- coding: utf-8 -*-
2
# -*- encoding: utf-8 -*-
3
##############################################################################
5
# OpenERP - Account balance reporting engine
6
# Copyright (C) 2009 Pexego Sistemas Informáticos. All Rights Reserved
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.
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.
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/>.
22
##############################################################################
25
Account balance report print wizard
27
__author__ = "Borja López Soilán (Pexego)"
30
from osv import fields, osv
34
class print_wizard(osv.osv_memory):
35
_name='account.balance.reporting.print.wizard'
37
def _get_current_report_id(self, cr, uid, ctx):
38
rpt_facade = pooler.get_pool(cr.dbname).get('account.balance.reporting')
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
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]
51
if report.template_id and report.template_id.report_xml_id:
52
report_xml_id = report.template_id.report_xml_id.id
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)])
61
#print str(data.get('report_id'))
62
#print str(data['report_id'][0])
64
'ids': [data.get('report_id') and data['report_id'][0] or None],
65
'model':'account.balance.reporting',
68
rpt_facade = pooler.get_pool(cr.dbname).get('ir.actions.report.xml')
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
75
report_xml = rpt_facade.browse(cr, uid, [report_xml_id])[0]
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]},
82
return { 'type': 'ir.actions.act_window_close' }
85
'report_id' : fields.many2one('account.balance.reporting', "Report"),
86
'report_xml_id': fields.many2one('ir.actions.report.xml', "Design"),
90
'report_id': _get_current_report_id,
91
'report_xml_id': _get_current_report_xml_id