diff options
| author | Toufik Ben Jaa <tbe@odoo.com> | 2019-05-10 09:19:59 +0000 |
|---|---|---|
| committer | Toufik Ben Jaa <tbe@odoo.com> | 2019-05-10 13:38:36 +0000 |
| commit | f39a974cc22e554aac74ac094d940d55faf15ae5 (patch) | |
| tree | 120d5f171f0c1b60dfc34a62d89a231edec0f361 /addons/hr_contract/models | |
| parent | 625eaeecaf0a921af03fe0f684a120841fb6e882 (diff) | |
[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) <tbe@odoo.com>
Diffstat (limited to 'addons/hr_contract/models')
| -rw-r--r-- | addons/hr_contract/models/hr_contract.py | 6 |
1 files 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: |
