Hello All,
I have to calculate the Age based on entered Birth date of the employee.Please help me here with any idea.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello All,
I have to calculate the Age based on entered Birth date of the employee.Please help me here with any idea.
Hi,
For the same, there are a lot of codes available over the internet. If you check the following link you can see some samples: https://stackoverflow.com/questions/2217488/age-from-birthdate-in-python
from datetime import date
def calculate_age(born):
today = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
Also, see this module which computes the age of the employee: https://apps.odoo.com/apps/modules/10.0/hr_employee_age/
Refer the code and do accordingly.
Thanks
Hello
try with below code
from datetime import datetime
from dateutil.relativedelta import relativedelta
@api.multi
@api.depends('birth_date')
def _compute_age(self):
for emp in self:
age = relativedelta(datetime.now().date(), fields.Datetime.from_string(emp.birth_date)).years
emp.age = str(age) + " Years"
age = fields.Char(string="Age", compute="_compute_age")
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
0
مارس 16
|
4225 | ||
|
3
أكتوبر 23
|
1854 | ||
|
2
سبتمبر 23
|
5205 | ||
ODOO Studio Calculate
تم الحل
|
|
1
أكتوبر 18
|
4707 | |
|
5
يونيو 16
|
7786 |