summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2021-01-18 13:09:25 +0000
committerYannick Tivisse <yti@odoo.com>2021-01-18 13:09:25 +0000
commit3a0801521cbe5af5c96b2faa7dcd2665ac5eab66 (patch)
tree6495dfce77e2d94eed8168703d4eac03fb71d91d
parent71b342b8e16973eae9fdc3484b88ed135c5d2834 (diff)
[FIX] hr_contract: Add method to ease inheritance
-rw-r--r--addons/hr_contract/models/hr_employee.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/hr_contract/models/hr_employee.py b/addons/hr_contract/models/hr_employee.py
index f6c8f47c4ca..f1f8c478d78 100644
--- a/addons/hr_contract/models/hr_employee.py
+++ b/addons/hr_contract/models/hr_employee.py
@@ -17,10 +17,14 @@ class Employee(models.Model):
contract_warning = fields.Boolean(string='Contract Warning', store=True, compute='_compute_contract_warning', groups="hr.group_hr_user")
first_contract_date = fields.Date(compute='_compute_first_contract_date', groups="hr.group_hr_user")
+ def _get_first_contracts(self):
+ self.ensure_one()
+ return self.sudo().contract_ids.filtered(lambda c: c.state != 'cancel')
+
@api.depends('contract_ids.state')
def _compute_first_contract_date(self):
for employee in self:
- contracts = employee.sudo().contract_ids.filtered(lambda c: c.state != 'cancel')
+ contracts = employee._get_first_contracts()
if contracts:
employee.first_contract_date = min(contracts.mapped('date_start'))
else: