1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from lxml import etree
24 from osv import osv, fields
25 from tools.translate import _
27 class account_bs_report(osv.osv_memory):
29 This wizard will provide the account balance sheet report by periods, between any two dates.
31 _name = 'account.bs.report'
32 _inherit = "account.common.account.report"
33 _description = 'Account Balance Sheet Report'
36 'display_type': fields.boolean("Landscape Mode"),
37 'reserve_account_id': fields.many2one('account.account', 'Reserve & Profit/Loss Account',required = True,
38 help='This Account is used for trasfering Profit/Loss(If It is Profit: Amount will be added, Loss : Amount will be duducted.), Which is calculated from Profilt & Loss Report', domain = [('type','=','payable')]),
46 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
47 res = super(account_bs_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
48 doc = etree.XML(res['arch'])
49 nodes = doc.xpath("//field[@name='journal_ids']")
51 node.set('readonly', '1')
52 node.set('required', '0')
53 res['arch'] = etree.tostring(doc)
56 def _print_report(self, cr, uid, ids, data, context=None):
59 data = self.pre_print_report(cr, uid, ids, data, context=context)
60 account = self.pool.get('account.account').browse(cr, uid, data['form']['chart_account_id'])
61 if not account.company_id.property_reserve_and_surplus_account:
62 raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !'))
63 data['form']['reserve_account_id'] = account.company_id.property_reserve_and_surplus_account.id
64 data['form'].update(self.read(cr, uid, ids, ['display_type'])[0])
65 if data['form']['display_type']:
67 'type': 'ir.actions.report.xml',
68 'report_name': 'account.balancesheet.horizontal',
73 'type': 'ir.actions.report.xml',
74 'report_name': 'account.balancesheet',
80 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: