PURPOSE This module enables the Booths registration on the frontend by adding a dedicated page on the related event. The user will have to first select a booth category and then select one or more booths to book. He will then be asked to provide his contact informations. The booths will directly be set to unavailable... First come, first served. LINKS Task-2318655 Closes : odoo/odoo#71104
56 lines
2.3 KiB
Python
56 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models, _
|
|
from odoo.addons.http_routing.models.ir_http import slug
|
|
|
|
|
|
class Event(models.Model):
|
|
_inherit = 'event.event'
|
|
|
|
exhibition_map = fields.Image(string='Exhibition Map', max_width=1024, max_height=1024)
|
|
# frontend menu management
|
|
booth_menu = fields.Boolean(
|
|
string='Booth Register', compute='_compute_booth_menu',
|
|
readonly=False, store=True)
|
|
booth_menu_ids = fields.One2many(
|
|
'website.event.menu', 'event_id', string='Event Booths Menus',
|
|
domain=[('menu_type', '=', 'booth')])
|
|
|
|
@api.depends('event_type_id', 'website_menu')
|
|
def _compute_booth_menu(self):
|
|
for event in self:
|
|
if event.event_type_id and event.event_type_id != event._origin.event_type_id:
|
|
event.booth_menu = event.event_type_id.booth_menu
|
|
elif event.website_menu and (event.website_menu != event._origin.website_menu or not event.booth_menu):
|
|
event.booth_menu = True
|
|
elif not event.website_menu:
|
|
event.booth_menu = False
|
|
|
|
# ------------------------------------------------------------
|
|
# WEBSITE MENU MANAGEMENT
|
|
# ------------------------------------------------------------
|
|
|
|
def toggle_booth_menu(self, val):
|
|
self.booth_menu = val
|
|
|
|
def _get_menu_update_fields(self):
|
|
return super(Event, self)._get_menu_update_fields() + ['booth_menu']
|
|
|
|
def _update_website_menus(self, menus_update_by_field=None):
|
|
super(Event, self)._update_website_menus(menus_update_by_field=menus_update_by_field)
|
|
for event in self:
|
|
if event.menu_id and (not menus_update_by_field or event in menus_update_by_field.get('booth_menu')):
|
|
event._update_website_menu_entry('booth_menu', 'booth_menu_ids', 'booth')
|
|
|
|
def _get_menu_type_field_matching(self):
|
|
res = super(Event, self)._get_menu_type_field_matching()
|
|
res['booth'] = 'booth_menu'
|
|
return res
|
|
|
|
def _get_website_menu_entries(self):
|
|
self.ensure_one()
|
|
return super(Event, self)._get_website_menu_entries() + [
|
|
(_('Get A Booth'), '/event/%s/booth' % slug(self), False, 90, 'booth')
|
|
]
|