3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
27
class wizard_create_analytics(wizard.interface):
31
form = '''<?xml version="1.0"?>
32
<form string="Process Form">
33
<field name="company_id"/>
39
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company'},
40
'type': {'string':'Type', 'type':'selection', 'selection':[('bydeg','By Employee Function'), ('byallded','By Allownce / Deduction')]}
43
def _get_defaults(self, cr, user, data, context):
44
#TODO : initlize required data
49
def _do_duplicate(self, cr, uid, data, context):
50
pool = pooler.get_pool(cr.dbname)
51
account_pool = pool.get('account.analytic.account')
52
func_pool = pool.get('hr.employee.grade')
53
ad_pool = pool.get('hr.allounce.deduction.categoty')
55
tpy = data['form']['type']
56
company = data['form']['company_id']
58
function_ids = func_pool.search(cr, uid, [])
59
ad_ids = ad_pool.search(cr, uid, [])
62
for function in func_pool.browse(cr, uid, function_ids):
67
fid = account_pool.create(cr, uid, res)
69
'name':'Basic Salary',
73
account_pool.create(cr, uid, res)
74
for ad in ad_pool.browse(cr, uid, ad_ids):
80
account_pool.create(cr, uid, res)
84
elif tpy == 'byallded':
86
'name':'Basic Salary',
89
adid = account_pool.create(cr, uid, res)
90
for function in func_pool.browse(cr, uid, function_ids):
96
account_pool.create(cr, uid, res)
98
for ad in ad_pool.browse(cr, uid, ad_ids):
101
'company_id':company,
103
adid = account_pool.create(cr, uid, res)
104
for function in func_pool.browse(cr, uid, function_ids):
106
'name':function.name,
107
'company_id':company,
110
account_pool.create(cr, uid, res)
116
'actions': [_get_defaults],
117
'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel'), ('process', 'Process'))},
120
'actions': [_do_duplicate],
121
'result': {'type': 'state', 'state': 'end'},
124
wizard_create_analytics('payroll.analysis')