[IMP] hr_employee: Add util method to retrieve employee's age method

Part-of: odoo/odoo#135508
This commit is contained in:
dasz
2023-09-28 15:48:22 +00:00
committed by Yannick Tivisse
parent 9fc8492259
commit 2ce2b30591
+6
View File
@@ -526,6 +526,12 @@ class HrEmployeePrivate(models.Model):
datetime.combine(fields.Date.from_string(date_to), time.max).replace(tzinfo=UTC)
)
def _get_age(self, target_date=None):
self.ensure_one()
if target_date is None:
target_date = fields.Date.context_today(self.env.user)
return relativedelta(target_date, self.birthday).years if self.birthday else 0
# ---------------------------------------------------------
# Messaging
# ---------------------------------------------------------