[FIX] website_event: correctly cleanup when removing event website menu
Currently if event website menu main checkbox is unchecked the related website menu is removed. Its children are also removed through the cascade attribute on parent_id field. However this is done in SQL, meaning some overrides on unlink of website.menu is not called. This does not properly cascade unlink views linked to website menus through the specific "website.event.menu" model. This leads to some views staying alive in DB. This causes issues with web editor when calling ``_views_get`` as he may receive several views linked to a given view_id (key) while it expects only one. We fix that behavior by removing the menu and its children explicitly. This calls various overrides done in website_event. Task-2616588 X-original-commit: 9722baee83adea9808de1247c300e226cf6fc537 Part-of: odoo/odoo#80391
This commit is contained in:
@@ -301,7 +301,9 @@ class Event(models.Model):
|
||||
:param menus_update_by_field: see ``_get_menus_update_by_field``"""
|
||||
for event in self:
|
||||
if event.menu_id and not event.website_menu:
|
||||
event.menu_id.sudo().unlink()
|
||||
# do not rely on cascade, as it is done in SQL -> not calling override and
|
||||
# letting some ir.ui.views in DB
|
||||
(event.menu_id + event.menu_id.child_id).sudo().unlink()
|
||||
elif event.website_menu and not event.menu_id:
|
||||
root_menu = self.env['website.menu'].sudo().create({'name': event.name, 'website_id': event.website_id.id})
|
||||
event.menu_id = root_menu
|
||||
|
||||
Reference in New Issue
Block a user