[FIX] website_event: website menu on event not working

Commit 7077f18e3 tried to fix the website event menu issue.
But the fix was wrong and fixed only the event having a website_id set.
After the 7077f18e3 fix, event with a website_id set are working as expected
but the ones without a website_id are not working.
Indeed, it will create a website.menu without a website_id which will result in
the menu being duplicated for each website (multi-website rule).
The required on website_id when activating website menu on event was trying to
hide that new issue but it was problematic since:
1. We were removing a feature for no reason as it would not be possible anymore
   to create a generic event (no website) with website menu activated.
2. The required would only work in form view, demo data or custo data loaded
   through xml without a website_id but having website menu activated would
   still bug and would not have a menu. Worst, the menu would be duplicated for
   every website and added to the website navbar.

Now, regardless of the event having a website_id set or not, activating or
deactivating event menu will work.

closes odoo/odoo#29036
This commit is contained in:
Romain Derie
2018-11-26 15:04:57 +00:00
parent 6f37e2cc5d
commit a67553c9d2
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -1100,7 +1100,7 @@ class Menu(models.Model):
if vals.get('url') == '/default-main-menu':
return super(Menu, self).create(vals)
if vals.get('website_id'):
if 'website_id' in vals:
return super(Menu, self).create(vals)
elif self._context.get('website_id'):
vals['website_id'] = self._context.get('website_id')
+1 -1
View File
@@ -31,7 +31,7 @@
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<field name="organizer_id" position="before">
<field name="website_id" options="{'no_create': True}" attrs="{'required': [('website_menu','=',True)]}" groups="website.group_multi_website"/>
<field name="website_id" options="{'no_create': True}" groups="website.group_multi_website"/>
</field>
<button name="toggle_active" position="before">
<field name="website_url" invisible="1"/>