[IMP] account: bank statement reconciliation widget (part 3: missing files lost durin...
[odoo/odoo.git] / addons / account / wizard / account_report_general_ledger.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 openerp.osv import fields, osv
23
24
25 class account_report_general_ledger(osv.osv_memory):
26     _inherit = "account.common.account.report"
27     _name = "account.report.general.ledger"
28     _description = "General Ledger Report"
29
30     _columns = {
31         'landscape': fields.boolean("Landscape Mode"),
32         'initial_balance': fields.boolean('Include Initial Balances',
33                                     help='If you selected to filter by date or period, this field allow you to add a row to display the amount of debit/credit/balance that precedes the filter you\'ve set.'),
34         'amount_currency': fields.boolean("With Currency", help="It adds the currency column on report if the currency differs from the company currency."),
35         'sortby': fields.selection([('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], 'Sort by', required=True),
36         'journal_ids': fields.many2many('account.journal', 'account_report_general_ledger_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
37     }
38     _defaults = {
39         'landscape': True,
40         'amount_currency': True,
41         'sortby': 'sort_date',
42         'initial_balance': False,
43     }
44
45     def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, context=None):
46         res = {}
47         if not fiscalyear:
48             res['value'] = {'initial_balance': False}
49         return res
50
51     def _print_report(self, cr, uid, ids, data, context=None):
52         if context is None:
53             context = {}
54         data = self.pre_print_report(cr, uid, ids, data, context=context)
55         data['form'].update(self.read(cr, uid, ids, ['landscape',  'initial_balance', 'amount_currency', 'sortby'])[0])
56         if not data['form']['fiscalyear_id']:# GTK client problem onchange does not consider in save record
57             data['form'].update({'initial_balance': False})
58
59         if data['form']['landscape'] is False:
60             data['form'].pop('landscape')
61
62         return self.pool['report'].get_action(cr, uid, [], 'account.report_generalledger', data=data, context=context)
63
64 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: