summaryrefslogtreecommitdiff
path: root/addons/hr_contract/models
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-05-13 11:02:27 +0200
committerChristophe Simonis <chs@odoo.com>2019-05-13 11:02:27 +0200
commit60e71302a38b36214efec1213882f573e3ea453c (patch)
treed6c4f548ac29c94891a52444887a230a7c30d403 /addons/hr_contract/models
parent3936d655c4bfd845b6ead724cecdc8e7c62816eb (diff)
parent243a4ae5cbc07027cd3eaf0ead036b9d3586dea3 (diff)
[MERGE] forward port branch saas-12.2 up to 243a4ae5cbc
Diffstat (limited to 'addons/hr_contract/models')
-rw-r--r--addons/hr_contract/models/hr_contract.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/addons/hr_contract/models/hr_contract.py b/addons/hr_contract/models/hr_contract.py
index bf1c5fbd58f..cf7ec0d6549 100644
--- a/addons/hr_contract/models/hr_contract.py
+++ b/addons/hr_contract/models/hr_contract.py
@@ -29,16 +29,13 @@ class Employee(models.Model):
"""
Returns the contracts of the employee between date_from and date_to
"""
- # a contract is valid if it ends between the given dates
- clause_1 = ['&', ('date_end', '<=', date_to), ('date_end', '>=', date_from)]
- # OR if it starts between the given dates
- clause_2 = ['&', ('date_start', '<=', date_to), ('date_start', '>=', date_from)]
- # OR if it starts before the date_from and finish after the date_end (or never finish)
- clause_3 = ['&', ('date_start', '<=', date_from), '|', ('date_end', '=', False), ('date_end', '>=', date_to)]
- clause_final = expression.AND([
- [('employee_id', 'in', self.ids), ('state', 'in', states)],
- expression.OR([clause_1, clause_2, clause_3])])
- return self.env['hr.contract'].search(clause_final)
+ return self.env['hr.contract'].search([
+ '&', '&', '&',
+ ('employee_id', 'in', self.ids),
+ ('state', 'in', states),
+ ('date_start', '<=', date_to),
+ '|', ('date_end', '=', False), ('date_end', '>=', date_from)
+ ])
@api.model
def _get_all_contracts(self, date_from, date_to, states=['open', 'pending']):