From a1f57e1ab5bc8bef339c63a3c9b3614921a1a230 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 5 Sep 2016 11:08:54 +0200 Subject: [PATCH] Block refusal of his own holidays --- hr_holidays_usability/hr_holidays.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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'