← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 783670] Re: account - level - wrong computation

 

Note:

1) I don't think the code makes any assumption that the parent's level is already calculated, because it recursively calls the function field, which should be computed on-demand, as far as I can see. However the process of doing this is a bit inefficient. I think the computed values should be correct, provided the tree hierarchy is correct and did not change, because of 2).
It is not easy to implement this in an efficient way (in terms of DB queries). A possible approach might be to use cr.execute('SELECT id, parent_id WHERE parent_left < %s', account.parent_left), which will return pairs of (id, parent_id) for all possible ancestors of the current account, and then post-process these in python by putting the pairs in a map and walking up from the node's parent.

2) That's quite correct indeed, the values should be recomputed when the
hierarchy changes, e.g. via a different "store=..." trigger.

-- 
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