I'm working on OpenERP7 in a customized report of balance.
print "registers ", len(account_move_line_search)
print "start ", time.strftime("%Y-%m-%d %H:%M:%S")
account_account_search = account_account_pool.search(cr, uid, [('level','=',5)])
for account_account in account_account_pool.browse(cr,uid,account_account_search):
account_move_line_search_inicial = account_move_line_pool.search(cr,uid,[('move_id.date','<=',self_browse.end_date),
('account_id','=',account_account.id)])
sum_cuenta_debit = 0.00
sum_cuenta_credit = 0.00
for account_move_line in account_move_line_pool.browse(cr,uid,account_move_line_search_inicial):
sum_cuenta_debit += account_move_line.debit
sum_cuenta_credit += account_move_line.credit
total_asientos += 1
mis_cuentas.append([account_account.id,
account_account.parent_id.id,
account_account.parent_id.parent_id.id,
account_account.parent_id.parent_id.parent_id.id,
account_account.parent_id.parent_id.parent_id.parent_id.id,
sum_cuenta_debit,
sum_cuenta_credit])
print "end ", time.strftime("%Y-%m-%d %H:%M:%S")
The report takes seats, in Date Range (do not take the date of account_move_line).
My work code it's to get the necessary values (debit,credit,account_id,account_id_level_4,account_id_level_3,account_id_level_2,account_id_level_1).
With a sample of 14580 records of 10 days, movements of my jornuas, it takes 47 seconds (too in my opinion).
When I place my search more filters, takes longer.
Is there any way to simplify this time ?.
or, my work code its bad?, I should do?
It welcomes comments.