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 openerp.osv import fields, osv
24 class account_report_general_ledger(osv.osv_memory):
25 _inherit = "account.common.account.report"
26 _name = "account.report.general.ledger"
27 _description = "General Ledger Report"
30 'landscape': fields.boolean("Landscape Mode"),
31 'initial_balance': fields.boolean('Include Initial Balances',
32 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.'),
33 'amount_currency': fields.boolean("With Currency", help="It adds the currency column on report if the currency differs from the company currency."),
34 'sortby': fields.selection([('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], 'Sort by', required=True),
35 'journal_ids': fields.many2many('account.journal', 'account_report_general_ledger_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
39 'amount_currency': True,
40 'sortby': 'sort_date',
41 'initial_balance': False,
44 def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, context=None):
47 res['value'] = {'initial_balance': False}
50 def _print_report(self, cr, uid, ids, data, context=None):
53 data = self.pre_print_report(cr, uid, ids, data, context=context)
54 data['form'].update(self.read(cr, uid, ids, ['landscape', 'initial_balance', 'amount_currency', 'sortby'])[0])
55 if not data['form']['fiscalyear_id']:# GTK client problem onchange does not consider in save record
56 data['form'].update({'initial_balance': False})
57 if data['form']['landscape']:
58 return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger_landscape', 'datas': data}
59 return { 'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger', 'datas': data}
61 account_report_general_ledger()
63 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: