Files
odoo_source/addons/event_booth/tests/test_event_internals.py
T
Patrick Hoste 3c5c3c257e [ADD] event_booth: add booths management for events
PURPOSE

This new module adds a booths management capabilities to the event module.
The event manager will be able to manage booking to physical booths hosted
at his event by first creating several booths categories depending for example
on the booths size, the number of tables, extra services, ...
He will then create the actual booths to offer to the final users.

This module adds two main models :
- Event Booth Category which is used to differenciate the booths type.
- Event Booth which is the actual Booth that will be booked.

The booking is done directly on the booth form view by setting a partner and
his contact informations and by setting the booth state to unavailable.
If the event manager want to book a booth for later use he can set the state
to unavailable without setting a partner.

The booking of a booth will be displayed in the chatter of the related event
to ease the event manager overview

The user manager can use event template to adds booths by default when setting
the template to an event.

LINKS

Task-2318655
Closes : odoo/odoo#71104
2021-09-02 14:14:32 +00:00

92 lines
4.0 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import datetime, timedelta
from odoo import Command
from odoo.addons.event_booth.tests.common import TestEventBoothCommon
from odoo.fields import Datetime as FieldsDatetime
from odoo.tests.common import users, Form
class TestEventData(TestEventBoothCommon):
@users('user_eventmanager')
def test_event_configuration_booths_from_type(self):
""" Test data computation (related to booths) of event coming from its event.type template. """
# setup test records
event_type_nobooth = self.env['event.type'].create({
'name': 'No booth',
})
event_type_wbooths = self.env['event.type'].create({
'name': 'Using booths',
'event_type_booth_ids': [
Command.clear(),
Command.create({
'name': 'Standard Booth',
'booth_category_id': self.event_booth_category_1.id,
}),
Command.create({
'name': 'Premium Booth',
'booth_category_id': self.event_booth_category_2.id,
})
]
})
# no booth by default as no booths on type
event = self.env['event.event'].create({
'name': 'Event',
'date_begin': FieldsDatetime.to_string(datetime.today() + timedelta(days=1)),
'date_end': FieldsDatetime.to_string(datetime.today() + timedelta(days=15)),
'event_type_id': event_type_nobooth.id
})
self.assertEqual(event.event_booth_ids, self.env['event.booth'])
# manually create booths: ok
event.write({
'event_booth_ids': [
Command.create({
'name': 'Custom Standard Booth 1',
'booth_category_id': self.event_booth_category_1.id,
}),
Command.create({
'name': 'Custom Standard Booth 2',
'booth_category_id': self.event_booth_category_1.id,
})
]
})
self.assertEqual(event.event_booth_count, 2)
self.assertEqual(event.event_booth_count_available, 2)
self.assertEqual(event.event_booth_category_ids, self.event_booth_category_1)
self.assertEqual(event.event_booth_ids[1].message_partner_ids, self.env['res.partner'])
# updating partner is independent from availability
event.event_booth_ids[1].write({'partner_id': self.event_customer.id})
self.assertEqual(event.event_booth_count, 2)
self.assertEqual(event.event_booth_count_available, 2)
self.assertEqual(event.event_booth_ids[1].message_partner_ids, self.event_customer)
# one booth is sold
event.event_booth_ids[1].write({'state': 'unavailable'})
self.assertEqual(event.event_booth_count, 2)
self.assertEqual(event.event_booth_count_available, 1)
# partner is reset: booth still unavailable but follower removed
event.event_booth_ids[1].write({'partner_id': False})
self.assertEqual(event.event_booth_count, 2)
self.assertEqual(event.event_booth_count_available, 1)
self.assertEqual(event.event_booth_ids[1].message_partner_ids, self.env['res.partner'])
# change event type to one using booths: include event type booths and keep reserved booths
event_form = Form(event)
event_form.event_type_id = event_type_wbooths
self.assertEqual(event_form.event_booth_count, 3)
self.assertEqual(
set(r['name'] for r in event_form.event_booth_ids._records),
set(('Custom Standard Booth 2', 'Standard Booth', 'Premium Booth')),
'Should keep booths with reservation, remove unused ones and add type ones'
)
event_form.save()
self.assertEqual(event.event_booth_count_available, 2)
self.assertEqual(event.event_booth_category_ids, self.event_booth_category_1 + self.event_booth_category_2)