[FIX] hr_holidays: employees cannot approve their holidays
Nor modify once approved It wasn't possible for employees to approve their holidays themself, thanks to the GUI, but this was possible through xmlrpc calls, or when altering the html directly in the browser. Besides, this was also possible to edit the holiday through the same trick once the holiday validated
This commit is contained in:
parent
bc3991b4c5
commit
9b3f3fecfe
|
@ -305,10 +305,14 @@ class hr_holidays(osv.osv):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
context = dict(context, mail_create_nolog=True)
|
context = dict(context, mail_create_nolog=True)
|
||||||
|
if values.get('state') and values['state'] not in ['draft', 'confirm', 'cancel'] and not self.pool['res.users'].has_group(cr, uid, 'base.group_hr_user'):
|
||||||
|
raise osv.except_osv(_('Warning!'), _('You cannot set a leave request as \'%s\'. Contact a human resource manager.') % values.get('state'))
|
||||||
return super(hr_holidays, self).create(cr, uid, values, context=context)
|
return super(hr_holidays, self).create(cr, uid, values, context=context)
|
||||||
|
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
def write(self, cr, uid, ids, vals, context=None):
|
||||||
check_fnct = self.pool.get('hr.holidays.status').check_access_rights
|
check_fnct = self.pool.get('hr.holidays.status').check_access_rights
|
||||||
|
if vals.get('state') and vals['state'] not in ['draft', 'confirm', 'cancel'] and not self.pool['res.users'].has_group(cr, uid, 'base.group_hr_user'):
|
||||||
|
raise osv.except_osv(_('Warning!'), _('You cannot set a leave request as \'%s\'. Contact a human resource manager.') % vals.get('state'))
|
||||||
for holiday in self.browse(cr, uid, ids, context=context):
|
for holiday in self.browse(cr, uid, ids, context=context):
|
||||||
if holiday.state in ('validate','validate1') and not check_fnct(cr, uid, 'write', raise_exception=False):
|
if holiday.state in ('validate','validate1') and not check_fnct(cr, uid, 'write', raise_exception=False):
|
||||||
raise osv.except_osv(_('Warning!'),_('You cannot modify a leave request that has been approved. Contact a human resource manager.'))
|
raise osv.except_osv(_('Warning!'),_('You cannot modify a leave request that has been approved. Contact a human resource manager.'))
|
||||||
|
|
|
@ -5,6 +5,17 @@
|
||||||
<field name="name">Employee Holidays</field>
|
<field name="name">Employee Holidays</field>
|
||||||
<field model="ir.model" name="model_id" ref="model_hr_holidays"/>
|
<field model="ir.model" name="model_id" ref="model_hr_holidays"/>
|
||||||
<field name="domain_force">[('employee_id.user_id','=',user.id)]</field>
|
<field name="domain_force">[('employee_id.user_id','=',user.id)]</field>
|
||||||
|
<field name="perm_create" eval="False"/>
|
||||||
|
<field name="perm_write" eval="False"/>
|
||||||
|
<field name="perm_unlink" eval="False"/>
|
||||||
|
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="property_rule_holidays_employee_write" model="ir.rule">
|
||||||
|
<field name="name">Employee Holidays Create, Write, Unlink</field>
|
||||||
|
<field model="ir.model" name="model_id" ref="model_hr_holidays"/>
|
||||||
|
<field name="domain_force">[('employee_id.user_id','=',user.id), ('state', 'in', ['draft', 'confirm', 'cancel'])]</field>
|
||||||
|
<field name="perm_read" eval="False"/>
|
||||||
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
|
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue