diff --git a/hr_holidays_usability/hr_holidays.py b/hr_holidays_usability/hr_holidays.py index ef05030..46b2881 100644 --- a/hr_holidays_usability/hr_holidays.py +++ b/hr_holidays_usability/hr_holidays.py @@ -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'