[FIX] customize menu

- regression introducted by elif
- hide non relevant option
- deterministic order of items

bzr revid: al@openerp.com-20140127205326-0o1vgbf45mvxllgv
This commit is contained in:
Antony Lesuisse 2014-01-27 21:53:26 +01:00
parent c974af606d
commit 87a1b0a459
1 changed files with 5 additions and 4 deletions

View File

@ -31,10 +31,9 @@ class view(osv.osv):
if isinstance(view, basestring):
mod_obj = self.pool.get("ir.model.data")
m, n = view.split('.')
_, view = mod_obj.get_object_reference(cr, uid, m, n)
view = mod_obj.get_object(cr, uid, m, n, context=context)
elif isinstance(view, (int, long)):
view_obj = self.pool.get("ir.ui.view")
view = view_obj.browse(cr, uid, view, context=context)
view = self.pool.get("ir.ui.view").browse(cr, uid, view, context=context)
return view
try:
@ -50,8 +49,10 @@ class view(osv.osv):
todo = view.inherit_children_ids
if options:
todo += filter(lambda x: not x.inherit_id, view.inherited_option_ids)
# Keep options in a determinitic order whatever their enabled disabled status
todo.sort(lambda x,y:cmp(x.id,y.id))
for child_view in todo:
for r in self._views_get(cr, uid, child_view, options=options, context=context, root=False, stack_result=result):
for r in self._views_get(cr, uid, child_view, options=bool(child_view.inherit_id), context=context, root=False, stack_result=result):
if r not in result:
result.append(r)
node = etree.fromstring(view.arch)