Files
odoo_source/addons/website_event/tests/test_event_visitor.py
T
Jérémy Hennecart (jeh) 4a20cb320b [IMP] *event*: remove autoconfirm
Remove autoconfirm logic and simplify the flow of event
registrations. Now a registration is by default considered
as confirmed.

The draft state is kept for registrations with
a payment pending.

These registrations are no longer counted
as expected attendees for the seats computation.
To match the behavior of events, we also add a seats_expected
computed field on event tickets.

The registration status is now based on the sale order state.
So the payment_status field is renamed sale_status.
We consider now that a registration linked to a SO in a sale
state should be confirmed and reserved.
A sale order is in the `sale` state when manually confirmed
or when the transactions done match the amount_total of the
sale order.

We also rename the seats_expected field into seats_taken to
better match the process. It was a bit weird to have expected
in the name when the registration attended were counted into it.

UPG PR: odoo/upgrade#4836

task-3061849

Part-of: odoo/odoo#126431
2023-10-13 07:33:49 +00:00

66 lines
2.5 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 fields
from odoo.addons.website.tests.test_website_visitor import WebsiteVisitorTests
from odoo.addons.website_event.tests.common import TestEventOnlineCommon
from odoo.tests import tagged
@tagged('website_visitor')
class TestEventVisitor(TestEventOnlineCommon, WebsiteVisitorTests):
def test_clean_inactive_visitors_event(self):
""" Visitors registered to events should not be deleted even if not connected recently. """
active_visitors = self.env['website.visitor'].create([{
'lang_id': self.env.ref('base.lang_en').id,
'country_id': self.env.ref('base.be').id,
'website_id': 1,
'last_connection_datetime': datetime.now() - timedelta(days=8),
'access_token': 'f9d2af99f543874642f89bd334fa4a49',
'event_registration_ids': [(0, 0, {
'event_id': self.event_0.id
})]
}])
self._test_unlink_old_visitors(self.env['website.visitor'], active_visitors)
def test_link_to_visitor_event(self):
""" Same as parent's 'test_link_to_visitor' except we also test that event
registrations are merged into main visitor. """
[main_visitor, linked_visitor] = self.env['website.visitor'].create([
self._prepare_main_visitor_data(),
self._prepare_linked_visitor_data()
])
event_1 = self.env['event.event'].create({
'name': 'OtherEvent',
'date_begin': fields.Datetime.to_string(datetime.today() + timedelta(days=1)),
'date_end': fields.Datetime.to_string(datetime.today() + timedelta(days=15)),
})
linked_visitor.write({
'event_registration_ids': [(0, 0, {
'event_id': event_1.id
})]
})
self.assertEqual(self.event_0, main_visitor.event_registered_ids)
self.assertEqual(event_1, linked_visitor.event_registered_ids)
linked_visitor._merge_visitor(main_visitor)
self.assertVisitorDeactivated(linked_visitor, main_visitor)
# main_visitor is now attending both events
self.assertEqual(self.event_0 | event_1, main_visitor.event_registered_ids)
def _prepare_main_visitor_data(self):
values = super()._prepare_main_visitor_data()
values.update({
'event_registration_ids': [(0, 0, {
'event_id': self.event_0.id
})]
})
return values