hi,
I want to add a field in the hr. contract module called notification_id that will be calculated automatically according to the contract types.
here's my code:
class ContractNotificationInherit(models.Model):
_inherit = 'hr.contract'
notification_id = fields.Many2one('hr.contract.notification', string="renew notification for contract",
required=True,
compute="set_notification_group")
@api.multi
@api.depends('type_id')
@api.model
def set_notification_group(self):
for rec in self.env['hr.contract'].search([]):
if rec == self.env['hr.contract.type'].search([("name", '=', 'Employee')]):
rec.notification_id = self.env['hr.contract.notification'].search([('name', '=', 'month')])
thank you in advance for any helps.