[FIX]: Fixed idea module parent category bug.
bzr revid: vro@tinyerp.com-20110414131417-hoponmoszarth5nl
This commit is contained in:
parent
ad0ececa4e
commit
8519b21aeb
|
@ -31,11 +31,28 @@ DefaultVoteValue = '50'
|
|||
class idea_category(osv.osv):
|
||||
""" Category of Idea """
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if not len(ids):
|
||||
return []
|
||||
reads = self.read(cr, uid, ids, ['name','parent_id'], context=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 _categ_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
|
||||
res = self.name_get(cr, uid, ids, context=context)
|
||||
return dict(res)
|
||||
|
||||
_name = "idea.category"
|
||||
_description = "Idea Category"
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Category', size=64, required=True),
|
||||
'complete_name': fields.function(_categ_name_get_fnc, method=True, type="char", string='Name'),
|
||||
'summary': fields.text('Summary'),
|
||||
'parent_id': fields.many2one('idea.category', 'Parent Categories', ondelete='set null'),
|
||||
'child_ids': fields.one2many('idea.category', 'parent_id', 'Child Categories'),
|
||||
|
@ -46,6 +63,10 @@ class idea_category(osv.osv):
|
|||
]
|
||||
_order = 'parent_id,name asc'
|
||||
|
||||
_constraints = [
|
||||
(osv.osv._check_recursion, 'Error ! You can not create recursive categories.', ['parent_id'])
|
||||
]
|
||||
|
||||
idea_category()
|
||||
|
||||
class idea_idea(osv.osv):
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Category of ideas">
|
||||
<field name="name"/>
|
||||
<field name="complete_name"/>
|
||||
<field name="parent_id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue