c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #24498
Re: [Bug 783670] Re: account - level - wrong computation
On 17. 05. 11 16:10, Ferdinand @ Camptocamp wrote:
> ad 1) for my chart of account the levels are not correct
>
> I dropped the level field to let it recalculate, but it's still wrong.
>
> may be it's due to my poor understanding of python and what (not)
> happens in detail, but this code seems not to be called recursively, I
> am missing a while.... condition
>
> IMHO it it calculated once for every account
>
> def _get_level(self, cr, uid, ids, field_name, arg, context=None):
> res={}
> accounts = self.browse(cr, uid, ids, context=context)
> for account in accounts:
> print >> sys.stderr,'account',account
> level = 0
> if account.parent_id:
> obj = self.browse(cr, uid, account.parent_id.id)
> print >> sys.stderr,'account obj',obj
> level = obj.level + 1
> res[account.id] = level
> return res
>
> account obj browse_record(account.account, 64)
> account browse_record(account.account, 78)
> account obj browse_record(account.account, 77)
> account browse_record(account.account, 79)
> account obj browse_record(account.account, 77)
> account browse_record(account.account, 210)
> account obj browse_record(account.account, 45)
> account browse_record(account.account, 211)
>
I hope that this won't sound too silly, but what's the use of this level
alltogether?? I can't see one.
thank you!
Bogdan
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/783670
Title:
account - level - wrong computation
Status in OpenERP Modules (addons):
Confirmed
Bug description:
account/account.py
def _get_level
currently the calculated level (except level 1) is very much random,
depending on the sequence of processed records
2 issues:
1) IMHO the function makes the wrong assumption that the level of the parent account is already calculated, which is not necessarily the case
2) the level (stored=True) of all childs must be recalculated if the level of a parent changes. IMHO this would also solve issue 1).
change of structure may be done any time manually.
References