[IMP] don't pointlessly recreate view_obj every time _views_get is called, better use of pool & data APIs
This commit is contained in:
parent
ad33728043
commit
85c466611a
|
@ -24,23 +24,26 @@ class view(osv.osv):
|
||||||
'page': False,
|
'page': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _view_obj(self, cr, uid, view_id, context=None):
|
||||||
|
if isinstance(view_id, basestring):
|
||||||
|
return self.pool['ir.model.data'].xmlid_to_object(
|
||||||
|
cr, uid, view_id, raise_if_not_found=True, context=context
|
||||||
|
)
|
||||||
|
elif isinstance(view_id, (int, long)):
|
||||||
|
return self.browse(cr, uid, view_id, context=context)
|
||||||
|
|
||||||
|
# assume it's already a view object (WTF?)
|
||||||
|
return view_id
|
||||||
|
|
||||||
# Returns all views (called and inherited) related to a view
|
# Returns all views (called and inherited) related to a view
|
||||||
# Used by translation mechanism, SEO and optional templates
|
# Used by translation mechanism, SEO and optional templates
|
||||||
def _views_get(self, cr, uid, view, options=True, context=None, root=True):
|
def _views_get(self, cr, uid, view_id, options=True, context=None, root=True):
|
||||||
if not context:
|
if not context:
|
||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
def view_obj(view):
|
|
||||||
if isinstance(view, basestring):
|
|
||||||
mod_obj = self.pool.get("ir.model.data")
|
|
||||||
m, n = view.split('.')
|
|
||||||
view = mod_obj.get_object(cr, uid, m, n, context=context)
|
|
||||||
elif isinstance(view, (int, long)):
|
|
||||||
view = self.pool.get("ir.ui.view").browse(cr, uid, view, context=context)
|
|
||||||
return view
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
view = view_obj(view)
|
view = self._view_obj(cr, uid, view_id, context=context)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Shall we log that ?
|
# Shall we log that ?
|
||||||
return []
|
return []
|
||||||
|
@ -53,7 +56,7 @@ class view(osv.osv):
|
||||||
node = etree.fromstring(view.arch)
|
node = etree.fromstring(view.arch)
|
||||||
for child in node.xpath("//t[@t-call]"):
|
for child in node.xpath("//t[@t-call]"):
|
||||||
try:
|
try:
|
||||||
call_view = view_obj(child.get('t-call'))
|
call_view = self._view_obj(cr, uid, child.get('t-call'), context=context)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
if call_view not in result:
|
if call_view not in result:
|
||||||
|
|
Loading…
Reference in New Issue