[REF] hr_holidays : Remove 'only-used-once' inline methods
Purpose ======= These methods were used only once in the models as they were very short we decided to simplify the code by inlining them
This commit is contained in:
@@ -330,16 +330,12 @@ class HolidaysRequest(models.Model):
|
||||
raise UserError(_('Leave request must be in Draft state ("To Submit") in order to confirm it.'))
|
||||
return self.write({'state': 'confirm'})
|
||||
|
||||
@api.multi
|
||||
def _check_security_action_approve(self):
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can approve leave requests.'))
|
||||
|
||||
@api.multi
|
||||
def action_approve(self):
|
||||
# if double_validation: this method is the first approval approval
|
||||
# if not double_validation: this method calls action_validate() below
|
||||
self._check_security_action_approve()
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can approve leave requests.'))
|
||||
|
||||
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
if any(holiday.state != 'confirm' for holiday in self):
|
||||
@@ -350,14 +346,10 @@ class HolidaysRequest(models.Model):
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def _check_security_action_validate(self):
|
||||
def action_validate(self):
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can approve leave requests.'))
|
||||
|
||||
@api.multi
|
||||
def action_validate(self):
|
||||
self._check_security_action_validate()
|
||||
|
||||
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
for holiday in self:
|
||||
if holiday.state not in ['confirm', 'validate1']:
|
||||
@@ -386,7 +378,8 @@ class HolidaysRequest(models.Model):
|
||||
|
||||
@api.multi
|
||||
def action_refuse(self):
|
||||
self._check_security_action_refuse()
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can refuse leave requests.'))
|
||||
|
||||
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
for holiday in self:
|
||||
@@ -405,11 +398,6 @@ class HolidaysRequest(models.Model):
|
||||
self._remove_resource_leave()
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def _check_security_action_refuse(self):
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can refuse leave requests.'))
|
||||
|
||||
####################################################
|
||||
# Messaging methods
|
||||
####################################################
|
||||
|
||||
@@ -189,16 +189,12 @@ class HolidaysAllocation(models.Model):
|
||||
raise UserError(_('Leave request must be in Draft state ("To Submit") in order to confirm it.'))
|
||||
return self.write({'state': 'confirm'})
|
||||
|
||||
@api.multi
|
||||
def _check_security_action_approve(self):
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can approve leave requests.'))
|
||||
|
||||
@api.multi
|
||||
def action_approve(self):
|
||||
# if double_validation: this method is the first approval approval
|
||||
# if not double_validation: this method calls action_validate() below
|
||||
self._check_security_action_approve()
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can approve leave requests.'))
|
||||
|
||||
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
if any(holiday.state != 'confirm' for holiday in self):
|
||||
@@ -209,14 +205,10 @@ class HolidaysAllocation(models.Model):
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def _check_security_action_validate(self):
|
||||
def action_validate(self):
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can approve leave requests.'))
|
||||
|
||||
@api.multi
|
||||
def action_validate(self):
|
||||
self._check_security_action_validate()
|
||||
|
||||
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
for holiday in self:
|
||||
if holiday.state not in ['confirm', 'validate1']:
|
||||
@@ -243,7 +235,8 @@ class HolidaysAllocation(models.Model):
|
||||
|
||||
@api.multi
|
||||
def action_refuse(self):
|
||||
self._check_security_action_refuse()
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can refuse leave requests.'))
|
||||
|
||||
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
for holiday in self:
|
||||
@@ -258,11 +251,6 @@ class HolidaysAllocation(models.Model):
|
||||
holiday.linked_request_ids.action_refuse()
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def _check_security_action_refuse(self):
|
||||
if not self.env.user.has_group('hr_holidays.group_hr_holidays_user'):
|
||||
raise UserError(_('Only an HR Officer or Manager can refuse leave requests.'))
|
||||
|
||||
####################################################
|
||||
# Messaging methods
|
||||
####################################################
|
||||
|
||||
@@ -8,7 +8,6 @@ from odoo.exceptions import UserError
|
||||
class AccountAnalyticLine(models.Model):
|
||||
_inherit = 'account.analytic.line'
|
||||
|
||||
# TODO: See if it is the right type
|
||||
holiday_id = fields.Many2one("hr.leave", string='Leave Request')
|
||||
|
||||
@api.multi
|
||||
|
||||
Reference in New Issue
Block a user