1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2011 TeMPO Consulting, MSF
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
##############################################################################
23
from osv import fields
25
from tools.translate import _
28
class payroll_setup(osv.osv_memory):
29
_name = 'payroll.setup'
30
_inherit = 'res.config'
33
'payroll_ok': fields.boolean(string='Is the system manage Payrolls ?'),
36
def default_get(self, cr, uid, fields, context=None):
38
Display the default value for payroll
40
setup_id = self.pool.get('unifield.setup.configuration').get_config(cr, uid)
41
res = super(payroll_setup, self).default_get(cr, uid, fields, context=context)
43
res['payroll_ok'] = setup_id.payroll_ok
48
def execute(self, cr, uid, ids, context=None):
50
Fill the payroll_ok field and active/de-activate the feature
52
assert len(ids) == 1, "We should only get one object from the form"
53
payload = self.browse(cr, uid, ids[0], context=context)
55
setup_obj = self.pool.get('unifield.setup.configuration')
56
setup_id = setup_obj.get_config(cr, uid)
59
payroll_ids = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'msf_homere_interface', 'menu_finance_payroll')[1]
62
if not payload.payroll_ok:
63
self.pool.get('ir.ui.menu').write(cr, uid, payroll_ids, {'active': False}, context=context)
65
self.pool.get('ir.ui.menu').write(cr, uid, payroll_ids, {'active': True}, context=context)
67
setup_obj.write(cr, uid, [setup_id.id], {'payroll_ok': payload.payroll_ok}, context=context)