How to subtract date now and birthday field then pass the age value in a field (readonly)?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
Hi Kasai,
You can calculate age using the following script:-
start = datetime.strptime(object.birthdate, DEFAULT_SERVER_DATE_FORMAT)
end = datetime.strptime(time.strftime(DEFAULT_SERVER_DATE_FORMAT), DEFAULT_SERVER_DATE_FORMAT)
delta = end - start
age = (delta.days / 365)
Please don't forget to import following:-
import time
from dateutil.relativedelta import relativedelta
from datetime import datetime
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
Hope this helps,, please let me know if it does.
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
1
Mar 22
|
3386 | ||
|
1
Mei 22
|
2198 | ||
Employee Date of Birth only with year 2005??????
Diselesaikan
|
|
3
Okt 15
|
4198 | |
odoo 16 dashboard select specific date range
Diselesaikan
|
|
3
Jun 25
|
1196 | |
How to get Creation Date for created Customer?
Diselesaikan
|
|
1
Jan 25
|
18028 |