Skip to content
Snippets Groups Projects
Commit f907ffde authored by Toufik Ben Jaa's avatar Toufik Ben Jaa
Browse files

[FIX] hr_payroll: allow to request leaves


- When having multiples contracts, at least one open and one closed, we may
  not be able to request a leave.

  This issue is triggered if the closed contract has no end date.
  The code checks if the leave you try create overlap over multiple contracts.
  But if a contract has no end date and is closed, the check may never
  succeed.

  So if a contract has no end date and is closed we don't take it in
  account.

closes odoo/odoo#32909

Signed-off-by: default avatarToufik Benjaa (tbe) <tbe@odoo.com>
parent fd0a1002
Branches
Tags
No related merge requests found
......@@ -53,7 +53,7 @@ class HrLeave(models.Model):
for leave in self.filtered(lambda l: l.employee_id):
contract = leave.employee_id._get_contracts(leave.date_from, leave.date_to, states=['open', 'pending', 'close'])
contract = leave.employee_id._get_contracts(leave.date_from, leave.date_to, states=['open', 'pending'])
if contract and contract.resource_calendar_id != leave.employee_id.resource_calendar_id:
resource_leave_values += [{
'name': leave.name,
......@@ -83,7 +83,9 @@ class HrLeave(models.Model):
('state', 'not in', ['draft', 'cancel']),
'|',
('date_end', '>=', holiday.date_from),
('date_end', '=', False),
'&',
('date_end', '=', False),
('state', '!=', 'close')
]
nbr_contracts = self.env['hr.contract'].sudo().search_count(domain)
if nbr_contracts > 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment