Hi everyone,
Currently I have 60k account.move.line records in my system, and i have to set a value of compute field so while the compute runs it takes lot of time to set the value in field for 60k records...
Please advise me how can I optimize that.
This is on priority , I have pasted the method below to make my question more clear
Thanks in Advance
Compute Method:
line_obj = self.env['account.move.line']
for rec in self:
if rec.account_id:
query = """SELECT sum(balance) from account_move_line where account_id = %s and create_date < %s and date <= %s and id != %s """
self.env.cr.execute(query, (rec.account_id.id, rec.create_date, rec.date, rec.id))
running_balance = self.env.cr.fetchone()[0] or 0.0
if rec.debit:
running_balance += rec.debit
if rec.credit:
running_balance -= rec.credit
rec.running_balance = running_balance
else:
rec.running_balance = 0.00