Meera Trambadia (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-783670-mtr into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #783670 in OpenERP Addons: "account - level - wrong computation"
  https://bugs.launchpad.net/openobject-addons/+bug/783670

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-783670-mtr/+merge/64800

account: calculates the correct level --fixes=lp:783670 
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-783670-mtr/+merge/64800
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-783670-mtr.
=== modified file 'account/account.py'
--- account/account.py	2011-05-18 15:36:04 +0000
+++ account/account.py	2011-06-16 09:41:39 +0000
@@ -340,9 +340,11 @@
         accounts = self.browse(cr, uid, ids, context=context)
         for account in accounts:
             level = 0
-            if account.parent_id:
-                obj = self.browse(cr, uid, account.parent_id.id)
-                level = obj.level + 1
+            parent_id =  account.parent_id
+            while parent_id:
+                obj = self.browse(cr, uid, parent_id.id)
+                level += 1
+                parent_id =  obj.parent_id
             res[account.id] = level
         return res
 
@@ -390,7 +392,10 @@
             'manage this. So if you import from another software system you may have to use the rate at date. ' \
             'Incoming transactions always use the rate at date.', \
             required=True),
-        'level': fields.function(_get_level, string='Level', method=True, store=True, type='integer'),
+        'level': fields.function(_get_level, string='Level', method=True, type='integer',
+             store={
+                    'account.account': (lambda self, cr, uid, ids, c={}: ids, ['parent_id'], 10),
+                   }),
     }
 
     _defaults = {

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to