summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2021-02-11 15:31:01 +0000
committerGoffin Simon <sig@odoo.com>2021-02-15 11:32:22 +0000
commit225550cd376da1a0dbafda4fb2a037825ec92b10 (patch)
treec103f4e907540ae528f408eb752b220cde119b90 /addons
parenteb31687b5c5733534634ae13448db3fb466f725d (diff)
[FIX] hr_holidays: Delete Time-Off request for own user/employee
Steps to reproducr the bug: - Let's consider an internal user U with no right in hr - Let's consider an employee E linked to U - Log with U - Create a hr.leave H with hr validation - Reset H to draft - Delete H Bug: An access right error was raised. opw:2443366 closes odoo/odoo#65993 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/hr_holidays/models/hr_leave.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py
index 356d912c87d..8d12097cdd9 100644
--- a/addons/hr_holidays/models/hr_leave.py
+++ b/addons/hr_holidays/models/hr_leave.py
@@ -307,7 +307,12 @@ class HolidaysRequest(models.Model):
@api.depends('holiday_status_id')
def _compute_state(self):
for holiday in self:
- holiday.state = 'confirm' if holiday.validation_type != 'no_validation' else 'draft'
+ if self.env.context.get('unlink') and holiday.state == 'draft':
+ # Otherwise the record in draft with validation_type in (hr, manager, both) will be set to confirm
+ # and a simple internal user will not be able to delete his own draft record
+ holiday.state = 'draft'
+ else:
+ holiday.state = 'confirm' if holiday.validation_type != 'no_validation' else 'draft'
@api.depends('request_date_from_period', 'request_hour_from', 'request_hour_to', 'request_date_from', 'request_date_to',
'request_unit_half', 'request_unit_hours', 'request_unit_custom', 'employee_id')
@@ -822,7 +827,7 @@ class HolidaysRequest(models.Model):
else:
for holiday in self.filtered(lambda holiday: holiday.state not in ['draft', 'cancel', 'confirm']):
raise UserError(error_message % (state_description_values.get(holiday.state),))
- return super(HolidaysRequest, self.with_context(leave_skip_date_check=True)).unlink()
+ return super(HolidaysRequest, self.with_context(leave_skip_date_check=True, unlink=True)).unlink()
def copy_data(self, default=None):
if default and 'date_from' in default and 'date_to' in default: