On 31/07/13 04:58 -0700, Jesús Martín Jiménez wrote:
> 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.I'm not sure to understand what you try to do. But the code that compute the balance is here: http://hg.tryton.org/modules/account/file/9bc358663f6d/account.py#l628 -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email/Jabber: [email protected] Website: http://www.b2ck.com/
pgplSQNK0dbzP.pgp
Description: PGP signature
