2010-08-27 10:30:13 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
##############################################################################
|
|
|
|
|
#
|
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
|
from openerp.osv import fields, osv
|
2010-08-27 10:30:13 +00:00
|
|
|
|
|
|
|
|
|
class account_tax_chart(osv.osv_memory):
|
|
|
|
|
"""
|
|
|
|
|
For Chart of taxes
|
|
|
|
|
"""
|
|
|
|
|
_name = "account.tax.chart"
|
|
|
|
|
_description = "Account tax chart"
|
|
|
|
|
_columns = {
|
|
|
|
|
'period_id': fields.many2one('account.period', \
|
|
|
|
|
'Period', \
|
|
|
|
|
),
|
2010-12-10 10:31:12 +00:00
|
|
|
|
'target_move': fields.selection([('posted', 'All Posted Entries'),
|
|
|
|
|
('all', 'All Entries'),
|
|
|
|
|
], 'Target Moves', required=True),
|
2010-08-27 10:30:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def _get_period(self, cr, uid, context=None):
|
|
|
|
|
"""Return default period value"""
|
2013-04-18 10:39:07 +00:00
|
|
|
|
period_ids = self.pool.get('account.period').find(cr, uid, context=context)
|
2010-08-31 09:48:53 +00:00
|
|
|
|
return period_ids and period_ids[0] or False
|
2010-08-27 10:30:13 +00:00
|
|
|
|
|
|
|
|
|
def account_tax_chart_open_window(self, cr, uid, ids, context=None):
|
|
|
|
|
"""
|
|
|
|
|
Opens chart of Accounts
|
|
|
|
|
@param cr: the current row, from the database cursor,
|
|
|
|
|
@param uid: the current user’s ID for security checks,
|
|
|
|
|
@param ids: List of account chart’s IDs
|
|
|
|
|
@return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
|
|
|
|
|
"""
|
|
|
|
|
mod_obj = self.pool.get('ir.model.data')
|
|
|
|
|
act_obj = self.pool.get('ir.actions.act_window')
|
|
|
|
|
if context is None:
|
|
|
|
|
context = {}
|
2011-02-01 21:08:39 +00:00
|
|
|
|
data = self.browse(cr, uid, ids, context=context)[0]
|
2010-10-28 08:35:00 +00:00
|
|
|
|
result = mod_obj.get_object_reference(cr, uid, 'account', 'action_tax_code_tree')
|
|
|
|
|
id = result and result[1] or False
|
2010-08-27 10:30:13 +00:00
|
|
|
|
result = act_obj.read(cr, uid, [id], context=context)[0]
|
2011-02-01 21:08:39 +00:00
|
|
|
|
if data.period_id:
|
|
|
|
|
result['context'] = str({'period_id': data.period_id.id, \
|
2011-02-28 11:08:58 +00:00
|
|
|
|
'fiscalyear_id': data.period_id.fiscalyear_id.id, \
|
2011-02-01 21:08:39 +00:00
|
|
|
|
'state': data.target_move})
|
2011-02-28 11:08:58 +00:00
|
|
|
|
period_code = data.period_id.code
|
|
|
|
|
result['name'] += period_code and (':' + period_code) or ''
|
2010-08-27 10:30:13 +00:00
|
|
|
|
else:
|
2011-02-01 21:08:39 +00:00
|
|
|
|
result['context'] = str({'state': data.target_move})
|
2010-08-27 10:30:13 +00:00
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
_defaults = {
|
|
|
|
|
'period_id': _get_period,
|
2010-12-10 10:31:12 +00:00
|
|
|
|
'target_move': 'posted'
|
2010-08-27 10:30:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-01 21:08:39 +00:00
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|