[IMP] HR: improve the code in res_config.py for hr_timesheet_sheet module and res_config.py for hr module

bzr revid: jap@tinyerp.com-20120403090404-j5gdfhwwkdkb82vw
This commit is contained in:
Jagdish Panchal (Open ERP)
2012-04-03 14:34:04 +05:30
parent f8ee3720e4
commit 571dd35fef
3 changed files with 13 additions and 34 deletions
-26
View File
@@ -41,34 +41,8 @@ class human_resources_configuration(osv.osv_memory):
help ="""It installs the hr_contract module."""),
'module_hr_evaluation': fields.boolean('Manage Appraisals Process',
help ="""It installs the hr_evaluation module."""),
'module_l10n_be_hr_payroll': fields.boolean('Allow to change Payroll Rules',
help ="""It allow to change payroll Rules."""),
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
ir_module = self.pool.get('ir.module.module')
payroll_id= ir_module.search(cr, uid, [('name','=','hr_payroll')])
recruitment_id= ir_module.search(cr, uid, [('name','=','hr_recruitment')])
timesheet_id= ir_module.search(cr, uid, [('name','=','hr_timesheet_sheet')])
payroll_modle_state = ir_module.browse(cr,uid, payroll_id[0],context=context).state
recruitment_modle_state = ir_module.browse(cr,uid, recruitment_id[0],context=context).state
timesheet_modle_state = ir_module.browse(cr,uid, timesheet_id[0],context=context).state
res = super(human_resources_configuration, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
doc = etree.XML(res['arch'])
if recruitment_modle_state == 'uninstalled':
for node in doc.xpath("//group[@name='Recruitment']"):
node.set('invisible', '1')
res['arch'] = etree.tostring(doc)
return res
human_resources_configuration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -15,6 +15,7 @@
<button name="%(action_create_hr_employee_installer)d" string="Employees" type="action" icon="gtk-apply"/>
<field name="module_hr_timesheet_sheet"/>
<field name="module_hr_holidays"/>
<field name="module_hr_payroll"/>
</group>
<separator string="Additional Features" colspan="4"/>
<group colspan="4" col="4">
+12 -8
View File
@@ -20,7 +20,7 @@
##############################################################################
from osv import osv, fields
import pooler
class hr_timeshee_settings(osv.osv_memory):
_name = 'human.resources.configuration'
_inherit = 'human.resources.configuration'
@@ -34,13 +34,17 @@ class hr_timeshee_settings(osv.osv_memory):
"computation for one sheet. Set this to 0 if you do not want any control."),
}
def default_get(self, cr, uid, fields, context=None):
ir_values = self.pool.get('ir.values')
res = super(hr_timeshee_settings, self).default_get(cr, uid, fields, context)
timesheet = ir_values.get_default(cr, uid, 'res.company', 'timesheet_range')
companies = self.pool.get('res.company').search(cr, uid, [], context=context)
for time_diff in self.pool.get('res.company').browse(cr, uid, companies, context=context):
res['timesheet_range']=time_diff.timesheet_range
res['timesheet_max_difference']=time_diff.timesheet_max_difference
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
res['timesheet_range']=user.company_id.timesheet_range
res['timesheet_max_difference']=user.company_id.timesheet_max_difference
return res
def set_timesheet_defaults(self, cr, uid, ids, context=None):
wizard = self.browse(cr, uid, ids)[0]
tm_range = wizard.timesheet_range
tm_diff = wizard.timesheet_max_difference
user = self.pool.get('res.users').browse(cr, uid, uid, context)
user.company_id.write({'timesheet_range': tm_range,'timesheet_max_difference': tm_diff})
return {}