summaryrefslogtreecommitdiff
path: root/addons/website_event_track/models
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-08-18 13:56:08 +0000
committerThibault Delavallée <tde@odoo.com>2020-08-21 17:30:13 +0000
commit77d7a3cf6a2cf07e18804a2d9b59e3697b11006e (patch)
tree435ca546a4b8eb5867dcd756e940b14e67513479 /addons/website_event_track/models
parent8da7288453d43ff6ccfd6cb6d8332eec998d3927 (diff)
[MOV] website_event(_track): move website event menu into website event
PURPOSE Clean organization and models linked to Event Online feature introduced in semi stable saas-13.3 at odoo/odoo@981f95bbf46658eda9f2d33751b9310cc67d86aa and odoo/enterprise@14722028ae0773c3710ea48ce48ff44703e83b5a Also clean website event menu not being available in website event but only in website event track, which implies some extra-code to manage it. In short: merge website_event_online in website_event, website_event_track _(online/session) in website_event_track. RATIONALE _online modules have been added to extend content of website_event and website_event_track without having any impact on those module. First step of cleaning is to move this content directly in base module. track_session module is mainly a rewrite of track module. Second step of cleaning is to move its content directly in website_event_track. SPECIFICATIONS Move website event menu model directly into website event. Website event menu model has been introduced to help dealing with event-specific menus and website menus. This is some kind of glue to synchronize both of them as people could either * update an event (website_menu, website_track) that updates website menus availability; * update menus through website that should update event field value and menu computation; Having a model introduced in website event track forces to have override and code split across website_event, website_event_track, and now also in both _online version of those two as menu management was improved. In this commit we simplify all this code by moving most of menu management code in website_event, leaving only business-specific code (fields and their menus) to sub modules. SPECIFICATIONS: WEBSITE EVENT MENU Make type required as we don't support entries without type. Indeed this model is used to automate menus generation / destruction, and not for hand-made menus. We therefore set type as required and add a cascade ondelete for selection. SPECIFCIATIONS: COMMUNITY MENU Doing this change allows to define community menu in website_event and re-use it in website_event_meet and website_event_track_quiz, removing some unnecessary dependencies. This menu is void in website_event, and displays either meeting rooms (in meet) or quiz points leaderboard (in quiz), or a mix of both if the two features are installed. LINKS Task ID-2319779 COM odoo/odoo#56067 ENT odoo/enterprise#12520 UPG odoo/upgrade#165
Diffstat (limited to 'addons/website_event_track/models')
-rw-r--r--addons/website_event_track/models/event_event.py56
-rw-r--r--addons/website_event_track/models/website_event_menu.py12
-rw-r--r--addons/website_event_track/models/website_menu.py3
3 files changed, 11 insertions, 60 deletions
diff --git a/addons/website_event_track/models/event_event.py b/addons/website_event_track/models/event_event.py
index 134999a50e7..7d7dc086077 100644
--- a/addons/website_event_track/models/event_event.py
+++ b/addons/website_event_track/models/event_event.py
@@ -85,53 +85,10 @@ class Event(models.Model):
if (not menus_update_by_field) or (event in menus_update_by_field.get('website_track_proposal')):
event._update_website_menu_entry('website_track_proposal', 'track_proposal_menu_ids', '_get_track_proposal_menu_entries')
- def _update_website_menu_entry(self, fname_bool, fname_o2m, method_name):
- """ Generic method to create menu entries based on a flag on event. This
- method is a bit obscure, but is due to preparation of adding new menus
- entries and pages for event in a stable version, leading to some constraints
- while developing.
-
- :param fname_bool: field name (e.g. website_track)
- :param fname_o2m: o2m linking towards website.event.menu matching the
- boolean fields (normally an entry ot website.event.menu with type matching
- the boolean field name)
- :param method_name: method returning menu entries information: url, sequence, ...
- """
- self.ensure_one()
- new_menu = None
-
- if self[fname_bool] and not self[fname_o2m]:
- # menus not found but boolean True: get menus to create
- for sequence, menu_data in enumerate(getattr(self, method_name)()):
- # some modules have 4 data: name, url, xml_id, menu_type; however we
- # plan to support sequence in future modules, so this hackish code is
- # necessary to avoid crashing. Not nice, but stable target = meh.
- if len(menu_data) == 4:
- (name, url, xml_id, menu_type) = menu_data
- menu_sequence = sequence
- elif len(menu_data) == 5:
- (name, url, xml_id, menu_sequence, menu_type) = menu_data
- new_menu = self._create_menu(menu_sequence, name, url, xml_id, menu_type=menu_type)
- elif not self[fname_bool]:
- # will cascade delete to the website.event.menu
- self[fname_o2m].mapped('menu_id').sudo().unlink()
-
- return new_menu
-
- def _create_menu(self, sequence, name, url, xml_id, menu_type=False):
- """ Override menu creation from website_event to link a website.event.menu
- to the newly create menu (either page and url). """
- website_menu = super(Event, self)._create_menu(sequence, name, url, xml_id, menu_type=menu_type)
- if menu_type:
- self.env['website.event.menu'].create({
- 'menu_id': website_menu.id,
- 'event_id': self.id,
- 'menu_type': menu_type,
- })
- return website_menu
-
def _get_menu_type_field_matching(self):
- return {'track_proposal': 'website_track_proposal'}
+ res = super(Event, self)._get_menu_type_field_matching()
+ res['track_proposal'] = 'website_track_proposal'
+ return res
def _get_track_menu_entries(self):
""" Method returning menu entries to display on the website view of the
@@ -146,10 +103,11 @@ class Event(models.Model):
"""
self.ensure_one()
return [
- (_('Talks'), '/event/%s/track' % slug(self), False, 'track'),
- (_('Agenda'), '/event/%s/agenda' % slug(self), False, False)]
+ (_('Talks'), '/event/%s/track' % slug(self), False, 10, 'track'),
+ (_('Agenda'), '/event/%s/agenda' % slug(self), False, 70, False)
+ ]
def _get_track_proposal_menu_entries(self):
""" See website_event_track._get_track_menu_entries() """
self.ensure_one()
- return [(_('Talk Proposals'), '/event/%s/track_proposal' % slug(self), False, 'track_proposal')]
+ return [(_('Talk Proposals'), '/event/%s/track_proposal' % slug(self), False, 15, 'track_proposal')]
diff --git a/addons/website_event_track/models/website_event_menu.py b/addons/website_event_track/models/website_event_menu.py
index aa00003a58a..70561b0a28a 100644
--- a/addons/website_event_track/models/website_event_menu.py
+++ b/addons/website_event_track/models/website_event_menu.py
@@ -5,12 +5,8 @@ from odoo import fields, models
class EventMenu(models.Model):
- _name = "website.event.menu"
- _description = "Website Event Menu"
+ _inherit = "website.event.menu"
- menu_id = fields.Many2one('website.menu', string='Menu', ondelete='cascade')
- event_id = fields.Many2one('event.event', string='Event', ondelete='cascade')
- menu_type = fields.Selection([
- ('track', 'Event Tracks Menus'),
- ('track_proposal', 'Event Proposals Menus'),
- ])
+ menu_type = fields.Selection(
+ selection_add=[('track', 'Event Tracks Menus'), ('track_proposal', 'Event Proposals Menus')],
+ ondelete={'track': 'cascade', 'track_proposal': 'cascade'})
diff --git a/addons/website_event_track/models/website_menu.py b/addons/website_event_track/models/website_menu.py
index 72377d4e7ce..703c3afbe8d 100644
--- a/addons/website_event_track/models/website_menu.py
+++ b/addons/website_event_track/models/website_menu.py
@@ -18,9 +18,6 @@ class WebsiteMenu(models.Model):
# agenda page that has also menu_type='track'
if event_menu.menu_type == 'track' and '/track' in event_menu.menu_id.url:
to_update.append('website_track')
- for menu_type, fname in event_menu.event_id._get_menu_type_field_matching().items():
- if event_menu.menu_type == menu_type:
- to_update.append(fname)
# call super that resumes the unlink of menus entries (including website event menus)
res = super(WebsiteMenu, self).unlink()