[FIX] hr_contract: Add method to ease inheritance
closes odoo/odoo#64723 X-original-commit: d32ff05d6b9a21cfd4ca711f66a21821e1014c7b Related: odoo/enterprise#15818 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -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", store=True)
|
||||
|
||||
def _get_first_contracts(self):
|
||||
self.ensure_one()
|
||||
return self.sudo().contract_ids.filtered(lambda c: c.state != 'cancel')
|
||||
|
||||
@api.depends('contract_ids.state', 'contract_ids.date_start')
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user