[IMP] website: add state of customize_view in cache
Add in one shot all the states (active or not) for all keys of customize_view task-2211013 Co-authored-by: Romain Derie <rde@odoo.com> Co-authored-by: Jeremy Kersten <jke@odoo.com>
This commit is contained in:
co-authored by
Romain Derie
parent
27de8b1478
commit
697f600784
@@ -698,14 +698,22 @@ class Website(models.Model):
|
||||
raise ValueError('No record found for unique ID %s. It may have been deleted.' % (view_id))
|
||||
return view
|
||||
|
||||
@tools.ormcache_context('key', keys=('website_id',))
|
||||
def is_view_active(self, key):
|
||||
"""
|
||||
Return True if active, False if not active, None if not found
|
||||
"""
|
||||
view = self.viewref(key, raise_if_not_found=False)
|
||||
return view.active if view else None
|
||||
@tools.ormcache_context(keys=('website_id',))
|
||||
def _cache_customize_show_views(self):
|
||||
views = self.env['ir.ui.view'].with_context(active_test=False).search([('customize_show', '=', True)])
|
||||
views = views.filter_duplicate()
|
||||
return {v.key: v.active for v in views}
|
||||
|
||||
@tools.ormcache_context('key', keys=('website_id',))
|
||||
def is_view_active(self, key, raise_if_not_found=False):
|
||||
"""
|
||||
Return True if active, False if not active, None if not found or not a customize_show view
|
||||
"""
|
||||
views = self._cache_customize_show_views()
|
||||
view = key in views and views[key]
|
||||
if view is None and raise_if_not_found:
|
||||
raise ValueError('No view of type customize_show found for key %s' % key)
|
||||
return view
|
||||
|
||||
@api.model
|
||||
def get_template(self, template):
|
||||
|
||||
Reference in New Issue
Block a user