Block refusal of his own holidays

This commit is contained in:
Alexis de Lattre
2016-09-05 11:08:54 +02:00
parent c2d2e93f07
commit a1f57e1ab5

View File

@@ -228,7 +228,8 @@ class HrHolidays(models.Model):
# The 'name' field is displayed publicly in the calendar
# So the label should not be 'Description' but 'Public Title'
name = fields.Char(
string='Public Title', help="Warning: this title is shown publicly in the "
string='Public Title',
help="Warning: this title is shown publicly in the "
"calendar. Don't write private/personnal information in this field.")
@api.one
@@ -381,6 +382,19 @@ class HrHolidays(models.Model):
res = super(HrHolidays, self).holidays_validate()
return res
@api.multi
def holidays_refuse(self):
for holi in self:
if (
holi.user_id == self.env.user and
not self.pool['res.users'].has_group(
self._cr, self._uid, 'base.group_hr_manager')):
raise UserError(_(
"You cannot refuse your own Leave or Allocation "
"holiday request '%s'.")
% holi.name)
return super(HrHolidays, self).holidays_refuse()
class ResCompany(models.Model):
_inherit = 'res.company'