From f39a974cc22e554aac74ac094d940d55faf15ae5 Mon Sep 17 00:00:00 2001 From: Toufik Ben Jaa Date: Fri, 10 May 2019 09:19:59 +0000 Subject: [PATCH] [FIX] hr_contract: allow to close employee's contracts - There's a constraint limiting the number of contracts an employee can have. This constraint take in account closed contract which cause issues. For example if you have to sign a new contract for an employee with a running contract, you'll have to close the current running contract. But if this employee already has closed contracts, you won't be able to close it since they are detected as ""running"" contracts. closes odoo/odoo#33294 Signed-off-by: Toufik Benjaa (tbe) --- addons/hr_contract/models/hr_contract.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_contract/models/hr_contract.py b/addons/hr_contract/models/hr_contract.py index 582d6121aaf..eef536458ad 100644 --- a/addons/hr_contract/models/hr_contract.py +++ b/addons/hr_contract/models/hr_contract.py @@ -108,12 +108,12 @@ class Contract(models.Model): @api.constrains('employee_id', 'state', 'date_start', 'date_end') def _check_current_contract(self): - """ Two contracts in state [incoming | pending | open | close] cannot overlap """ - for contract in self.filtered(lambda c: c.state not in ['draft', 'cancel']): + """ Two contracts in state [incoming | pending | open] cannot overlap """ + for contract in self.filtered(lambda c: c.state not in ['draft', 'cancel', 'close']): domain = [ ('id', '!=', contract.id), ('employee_id', '=', contract.employee_id.id), - ('state', 'in', ['incoming', 'pending', 'open', 'close']), + ('state', 'in', ['incoming', 'pending', 'open']), ] if not contract.date_end: