[REF] removed explicit model instanciations.
[odoo/odoo.git] / addons / account / project / wizard / account_analytic_chart.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 from openerp.osv import fields, osv
22
23 class account_analytic_chart(osv.osv_memory):
24     _name = 'account.analytic.chart'
25     _description = 'Account Analytic Chart'
26
27     _columns = {
28         'from_date': fields.date('From'),
29         'to_date': fields.date('To'),
30     }
31
32     def analytic_account_chart_open_window(self, cr, uid, ids, context=None):
33         mod_obj = self.pool.get('ir.model.data')
34         act_obj = self.pool.get('ir.actions.act_window')
35         result_context = {}
36         if context is None:
37             context = {}
38         result = mod_obj.get_object_reference(cr, uid, 'account', 'action_account_analytic_account_tree2')
39         id = result and result[1] or False
40         result = act_obj.read(cr, uid, [id], context=context)[0]
41         data = self.read(cr, uid, ids, [])[0]
42         if data['from_date']:
43             result_context.update({'from_date': data['from_date']})
44         if data['to_date']:
45             result_context.update({'to_date': data['to_date']})
46         result['context'] = str(result_context)
47         return result
48
49 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: