From d7cad67e0b8ec4a4956dc30f22e2c6e215eb057f Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Thu, 20 May 2010 20:03:43 +0530 Subject: [PATCH] [IMP]: implement new method that computes the level of account ref: developer by vra bzr revid: mga@tinyerp.com-20100520143343-cjk2u4fmjni6xjq9 --- addons/account/account.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/account/account.py b/addons/account/account.py index 88a9848f3bb..a3f66530bc3 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -297,6 +297,17 @@ class account_account(osv.osv): return result + def _get_level(self, cr, uid, ids, field_name, arg, context={}): + res={} + accounts = self.browse(cr, uid, ids) + for account in accounts: + level = 0 + if account.parent_id : + obj = self.browse(cr, uid, account.parent_id.id) + level = obj.level + 1 + res[account.id] = level + return res + _columns = { 'name': fields.char('Name', size=128, required=True, select=True), 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."), @@ -343,6 +354,7 @@ class account_account(osv.osv): 'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries when printing the General Ledger, "\ "otherwise it will only print its balance."), + 'level': fields.function(_get_level, string='Level', method=True, store=True, type='integer'), } def _default_company(self, cr, uid, context={}):