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 osv import osv, fields
23 from tools.translate import _
25 class account_bs_report(osv.osv_memory):
27 This wizard will provide the account balance sheet report by periods, between any two dates.
29 _name = 'account.bs.report'
30 _inherit = "account.common.account.report"
31 _description = 'Account Balance Sheet Report'
33 def _get_def_reserve_account(self, cr, uid, context=None):
34 chart_id = self._get_account(cr, uid, context=context)
35 res = self.onchange_chart_id(cr, uid, [], chart_id, context=context)
38 return res['value']['reserve_account_id']
41 'display_type': fields.boolean("Landscape Mode"),
42 'reserve_account_id': fields.many2one('account.account', 'Reserve & Profit/Loss Account',
44 help='This Account is used for transfering Profit/Loss ' \
45 '(Profit: Amount will be added, Loss: Amount will be duducted), ' \
46 'which is calculated from Profilt & Loss Report',
47 domain = [('type','=','payable')]),
53 'reserve_account_id': _get_def_reserve_account,
56 def onchange_chart_id(self, cr, uid, ids, chart_id, context=None):
59 account = self.pool.get('account.account').browse(cr, uid, chart_id , context=context)
60 if not account.company_id.property_reserve_and_surplus_account:
61 return {'value': {'reserve_account_id': False}}
62 return {'value': {'reserve_account_id': account.company_id.property_reserve_and_surplus_account.id}}
65 def _print_report(self, cr, uid, ids, data, context=None):
68 data['form'].update(self.read(cr, uid, ids, ['display_type','reserve_account_id'])[0])
69 if not data['form']['reserve_account_id']:
70 raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !'))
71 data = self.pre_print_report(cr, uid, ids, data, context=context)
72 if data['form']['display_type']:
74 'type': 'ir.actions.report.xml',
75 'report_name': 'account.balancesheet.horizontal',
80 'type': 'ir.actions.report.xml',
81 'report_name': 'account.balancesheet',
87 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: