Hi,
I'm trying to find out the breakdown of account.balance, so I'm making the
subtraction between account.credit and account.debit. The result I'm
obtaining always is 0 less 0 so I've supposed that I had to take care of
the account children. I computed credit and debit, taking care of their
children, this way:
balance = account.balance
accounts = Account.search([
('parent', 'child_of', [a.id for a in
accounts]),
], query_string=False)
credit_debit = Account.get_credit_debit(accounts,
['debit', 'credit'])
credit = sum([credit_debit['credit'][x]
for x in credit_debit['credit']])
debit = sum([credit_debit['debit'][x]
for x in credit_debit['debit']])
This is almost Ok, but for some account this is not correct yet. I thought
that issue was in the context I'm working, so I set it this way:
ctx = {
'fiscalyear': getattr(self.report,
getfiscalyear).id,
'periods': [p.id for p in getattr(self.report,
getperiods)],
'cumulate' : False,
}
with Transaction().set_context(ctx):
value = self._get_account_(template_value, mode) # *
in order to prevent that recursively call to get_credit_debit() method
overrides periods I'm trying to compute. But nothing changed.
Could someone say me what I'm missing?
* This is a call to the method where the code above is.
Cheers,