[FIX] website_theme_install: review post copy view toggling
If a theme post copy wants to enable/disable a view, this is to enable/disable a given functionality which is disabled/enabled by default. So if a post copy asks to enable/disable a view which is already enabled/disabled, we would not consider it otherwise it would COW the view for nothing. closes odoo/odoo#28772
This commit is contained in:
@@ -161,10 +161,23 @@ class Theme(models.AbstractModel):
|
||||
@api.model
|
||||
def _toggle_view(self, xml_id, active):
|
||||
obj = self.env.ref(xml_id)
|
||||
website = self.env['website'].get_current_website()
|
||||
if obj._name == 'theme.ir.ui.view':
|
||||
website = self.env['website'].get_current_website()
|
||||
obj = obj.with_context(active_test=False)
|
||||
obj = obj.copy_ids.filtered(lambda x: x.website_id == website)
|
||||
else:
|
||||
# If a theme post copy wants to enable/disable a view, this is to
|
||||
# enable/disable a given functionality which is disabled/enabled
|
||||
# by default. So if a post copy asks to enable/disable a view which
|
||||
# is already enabled/disabled, we would not consider it otherwise it
|
||||
# would COW the view for nothing.
|
||||
View = self.env['ir.ui.view'].with_context(active_test=False)
|
||||
has_specific = obj.key and View.search_count([
|
||||
('key', '=', obj.key),
|
||||
('website_id', '=', website.id)
|
||||
]) >= 1
|
||||
if not has_specific and active == obj.active:
|
||||
return
|
||||
obj.write({'active': active})
|
||||
|
||||
@api.model
|
||||
|
||||
Reference in New Issue
Block a user