From bff6e04e9536d7b80916987eb123de98b1b689b1 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sat, 10 Aug 2013 19:01:10 +0200 Subject: [PATCH] [IMP] Missing file added bzr revid: fp@tinyerp.com-20130810170110-3ltmqwnmfpytfh39 --- addons/website/view.py | 37 ++++++++++++++++++++++++ addons/website_crm/views/website_crm.xml | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 addons/website/view.py diff --git a/addons/website/view.py b/addons/website/view.py new file mode 100644 index 00000000000..af2224be4d9 --- /dev/null +++ b/addons/website/view.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +from lxml import etree +from openerp.osv import osv, fields + + +class view(osv.osv): + _inherit = "ir.ui.view" + _columns = { + 'inherit_option_id': fields.many2one('ir.ui.view','Optional Inheritancy'), + 'inherited_option_ids': fields.one2many('ir.ui.view','inherit_option_id','Optional Inheritancies'), + } + + # Returns all views (called and inherited) related to a view + # Used by translation mechanism, SEO and optional templates + def _views_get(self, cr, uid, view, options=True, context={}, root=True): + if type(view) in (str, unicode): + mod_obj = self.pool.get("ir.model.data") + m, n = view.split('.') + _, view = mod_obj.get_object_reference(cr, uid, m, n) + if type(view) == int: + view_obj = self.pool.get("ir.ui.view") + view = view_obj.browse(cr, uid, view, context=context) + while root and view.inherit_id: + view = view.inherit_id + + result = [view] + todo = view.inherit_children_ids + if options: + todo += filter(lambda x: not x.inherit_id, view.inherited_option_ids) + for child_view in todo: + result += self._views_get(cr, uid, child_view, options=options, context=context, root=False) + node = etree.fromstring(view.arch) + for child in node.xpath("//t[@t-call]"): + result += self._views_get(cr, uid, child.get('t-call'), options=options, context=context) + return result + diff --git a/addons/website_crm/views/website_crm.xml b/addons/website_crm/views/website_crm.xml index d849504940e..f4cd386d458 100644 --- a/addons/website_crm/views/website_crm.xml +++ b/addons/website_crm/views/website_crm.xml @@ -1,7 +1,7 @@ -