I am somehow a newbie to Odoo. I would like to ask for a solution maybe a code could help.
I got a module that inherit age with calculation from date_of_birth(dob) to my Main_Custom_Module (store=true) with the below :
from dateutil.relativedelta import relativedelta from odoo import api, fields, models class BitsBits(models.Model): _inherit = "bits.bits" age = fields.Integer(string="Age", readonly=True, compute="_compute_age") @api.depends("dob") def _compute_age(self): for record in self: age = 0 if record.dob: age = relativedelta(fields.Date.today(), record.dob).years record.age = age |
It's working perfectly.
Issue one: I have more than 50,000 record to upload to my main module. So i had to use pgadmin to do so. (All of records contains 'dob' date_of_birth field).
Question: How to make this field 'age' to be updated and calculated in Odoo when i upload data with 'dob' field directly to my databse ?
(cronjob maybe ?)Hope someone could cheer me up with this.
Thanks!
Thanks for anyone who watched and tried to figure out. But i made it.
and with Cronjob in Data folder to create a scheduled action.