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_tax_chart(osv.osv_memory):
28 _name = "account.tax.chart"
29 _description = "Account tax chart"
31 'period_id': fields.many2one('account.period', \
34 'target_move': fields.selection([('posted', 'All Posted Entries'),
35 ('all', 'All Entries'),
36 ], 'Target Moves', required=True),
39 def _get_period(self, cr, uid, context=None):
40 """Return default period value"""
41 ctx = dict(context or {}, account_period_prefer_normal=True)
42 period_ids = self.pool.get('account.period').find(cr, uid, context=ctx)
43 return period_ids and period_ids[0] or False
45 def account_tax_chart_open_window(self, cr, uid, ids, context=None):
47 Opens chart of Accounts
48 @param cr: the current row, from the database cursor,
49 @param uid: the current user’s ID for security checks,
50 @param ids: List of account chart’s IDs
51 @return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
53 mod_obj = self.pool.get('ir.model.data')
54 act_obj = self.pool.get('ir.actions.act_window')
57 data = self.browse(cr, uid, ids, context=context)[0]
58 result = mod_obj.get_object_reference(cr, uid, 'account', 'action_tax_code_tree')
59 id = result and result[1] or False
60 result = act_obj.read(cr, uid, [id], context=context)[0]
62 result['context'] = str({'period_id': data.period_id.id, \
63 'fiscalyear_id': data.period_id.fiscalyear_id.id, \
64 'state': data.target_move})
65 period_code = data.period_id.code
66 result['name'] += period_code and (':' + period_code) or ''
68 result['context'] = str({'state': data.target_move})
73 'period_id': _get_period,
74 'target_move': 'posted'
79 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: