Account analytic analysis
bzr revid: fp@tinyerp.com-d44367f3387e62a45e28d08079926b5d5a434074
This commit is contained in:
@@ -346,44 +346,3 @@ class account_analytic_account_summary_month(osv.osv):
|
||||
|
||||
account_analytic_account_summary_month()
|
||||
|
||||
class analytic_account_category(osv.osv):
|
||||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select distinct parent_id from account_analytic_account_category where id in ('+','.join(map(str,ids))+')')
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
return False
|
||||
level -= 1
|
||||
return True
|
||||
def name_get(self, cr, uid, ids, context={}):
|
||||
if not len(ids):
|
||||
return []
|
||||
reads = self.read(cr, uid, ids, ['name','parent_id'], context)
|
||||
res = []
|
||||
for record in reads:
|
||||
name = record['name']
|
||||
if record['parent_id']:
|
||||
name = record['parent_id'][1]+' / '+name
|
||||
res.append((record['id'], name))
|
||||
return res
|
||||
def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
|
||||
res = self.name_get(cr, uid, ids)
|
||||
return dict(res)
|
||||
_name = "account.analytic.account.category"
|
||||
_columns ={
|
||||
'name': fields.char('Category Name', required=True, size=64),
|
||||
'parent_id': fields.many2one('account.analytic.account.category', 'Parent Category', select=True),
|
||||
'complete_name': fields.function(_name_get_fnc, method=True, type="char", string='Name'),
|
||||
'child_ids': fields.one2many('account.analytic.account.category', 'parent_id', 'Childs Category'),
|
||||
'active' : fields.boolean('Active'),
|
||||
}
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive categories.', ['parent_id'])
|
||||
]
|
||||
_defaults = {
|
||||
'active' : lambda *a: 1,
|
||||
}
|
||||
analytic_account_category()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user