[ADD] account,account_followup : Tooltips added for the wizards
[odoo/odoo.git] / addons / account / wizard / account_report_balance_sheet.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
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.
11 #
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.
16 #
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/>.
19 #
20 ##############################################################################
21
22 from lxml import etree
23
24 from osv import osv, fields
25 from tools.translate import _
26
27 class account_bs_report(osv.osv_memory):
28     """
29     This wizard will provide the account balance sheet report by periods, between any two dates.
30     """
31     _name = 'account.bs.report'
32     _inherit = "account.common.account.report"
33     _description = 'Account Balance Sheet Report'
34
35     _columns = {
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')]),
39     }
40
41     _defaults={
42         'display_type': True,
43         'journal_ids': [],
44     }
45
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']")
50         for node in nodes:
51             node.set('readonly', '1')
52             node.set('required', '0')
53         res['arch'] = etree.tostring(doc)
54         return res
55
56     def _print_report(self, cr, uid, ids, data, context=None):
57         if context is None:
58             context = {}
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']:
66             return {
67                 'type': 'ir.actions.report.xml',
68                 'report_name': 'account.balancesheet.horizontal',
69                 'datas': data,
70             }
71         else:
72             return {
73                 'type': 'ir.actions.report.xml',
74                 'report_name': 'account.balancesheet',
75                 'datas': data,
76             }
77
78 account_bs_report()
79
80 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: