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

Requested reviews:
  qdp (OpenERP) (qdp)
  Mustufa Rangwala (Open ERP) (mra-tinyerp)
  Meera Trambadia (OpenERP) (mtr-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-07-01 23:41:24 +0000
+++ account/account.py	2011-07-05 12:45:50 +0000
@@ -332,17 +332,19 @@
                 for acc in record.child_consol_ids:
                     if acc.id not in result[record.id]:
                         result[record.id].append(acc.id)
-
+                        
         return result
-
+    
     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:
             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', store=True, type='integer'),
+        'level': fields.function(_get_level, string='Level', method=True, type='integer',
+             store={
+                    'account.account': (_get_children_and_consol, [], 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