Files
Odoo-Modules/fusion-plating/fusion_plating_culture/models/hr_employee.py
gsinghpal be611876ad changes
2026-04-12 09:09:50 -04:00

48 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from odoo import api, fields, models
class HrEmployee(models.Model):
"""Extend hr.employee with culture recognition totals.
Uses the x_fc_ prefix per the Fusion Central field-naming convention
for base Odoo model extensions.
"""
_inherit = 'hr.employee'
x_fc_recognition_ids = fields.One2many(
'fusion.plating.value.recognition',
'recognized_employee_id',
string='Recognitions',
)
x_fc_recognition_count = fields.Integer(
string='Recognition Count',
compute='_compute_x_fc_recognition_stats',
)
x_fc_last_recognized_date = fields.Datetime(
string='Last Recognized',
compute='_compute_x_fc_recognition_stats',
)
@api.depends(
'x_fc_recognition_ids',
'x_fc_recognition_ids.state',
'x_fc_recognition_ids.nomination_date',
)
def _compute_x_fc_recognition_stats(self):
for rec in self:
published = rec.x_fc_recognition_ids.filtered(
lambda r: r.state == 'published'
)
rec.x_fc_recognition_count = len(published)
if published:
rec.x_fc_last_recognized_date = max(
published.mapped('nomination_date')
)
else:
rec.x_fc_last_recognized_date = False