[REF] website_theme_install, *: add theme.utils utility methods
* theme_bootswatch, theme_default Allow to disable/enable a view from a xml_id whether the xml_id is linked to an ir.ui.view or a theme.ir.ui.view.
This commit is contained in:
@@ -4,4 +4,4 @@ class ThemeBootswatch(models.AbstractModel):
|
||||
_inherit = 'theme.utils'
|
||||
|
||||
def _theme_bootswatch_post_copy(self, mod):
|
||||
self.env.ref('website_theme_install.customize_modal').write({'active': False});
|
||||
self.disable_view('website_theme_install.customize_modal')
|
||||
|
||||
@@ -4,4 +4,4 @@ class ThemeDefault(models.AbstractModel):
|
||||
_inherit = 'theme.utils'
|
||||
|
||||
def _theme_default_post_copy(self, mod):
|
||||
self.env.ref('website_theme_install.customize_modal').write({'active': False});
|
||||
self.disable_view('website_theme_install.customize_modal')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import logging
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
from odoo.modules.module import get_resource_from_path
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -70,6 +70,21 @@ class Theme(models.AbstractModel):
|
||||
method = getattr(self.with_context(website_id=website.id), theme_post_copy)
|
||||
return method(mod)
|
||||
|
||||
@api.model
|
||||
def _toggle_view(self, xml_id, active):
|
||||
obj = self.env.ref(xml_id)
|
||||
if obj._name == 'theme.ir.ui.view':
|
||||
website = self.env['website'].get_current_website()
|
||||
obj = obj.copy_ids.filtered(lambda x: x.website_id == website)
|
||||
obj.write({'active': active})
|
||||
|
||||
@api.model
|
||||
def enable_view(self, xml_id):
|
||||
self._toggle_view(xml_id, True)
|
||||
|
||||
@api.model
|
||||
def disable_view(self, xml_id):
|
||||
self._toggle_view(xml_id, False)
|
||||
|
||||
class IrUiView(models.Model):
|
||||
_inherit = 'ir.ui.view'
|
||||
|
||||
Reference in New Issue
Block a user