diff --git a/event_sale_seat_reserve/models/sale_order_line.py b/event_sale_seat_reserve/models/sale_order_line.py index 15093c2ba..338edc8c0 100644 --- a/event_sale_seat_reserve/models/sale_order_line.py +++ b/event_sale_seat_reserve/models/sale_order_line.py @@ -1,7 +1,10 @@ # Copyright 2024 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). - +import logging from odoo import models +from odoo.tools import config + +_logger = logging.getLogger(__name__) class SaleOrderLine(models.Model): @@ -24,6 +27,11 @@ def _update_registrations( registrations = RegistrationSudo.search( [("sale_order_line_id", "in", self.ids), ("state", "=", "draft")] ) + if config["test_enable"] and not self.env.context.get("test_event_seat_reserve"): + _logger.info( + "Test mode is enabled, skipping the reservation of the seats" + ) + return res registrations.action_set_reserved() return res diff --git a/event_sale_seat_reserve/tests/test_event_sale_seat_reserve.py b/event_sale_seat_reserve/tests/test_event_sale_seat_reserve.py index 86a74e25e..6547b1a41 100644 --- a/event_sale_seat_reserve/tests/test_event_sale_seat_reserve.py +++ b/event_sale_seat_reserve/tests/test_event_sale_seat_reserve.py @@ -9,6 +9,9 @@ class TestEventSaleSeatReserve(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() + test_context = cls.env.context.copy() + test_context["test_event_seat_reserve"] = True + cls.env = cls.env(context=dict(test_context, tracking_disable=True)) # ../event/data/event_demo.xml # using this demo data, we have a max_seats = 4 # and 3 registrations diff --git a/test-requirements.txt b/test-requirements.txt index 07f6f0186..4e1e3d0e5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1 @@ -odoo-addon-event_seat_reserve @ git+https://github.com/OCA/event.git@refs/pull/394/head#subdirectory=event_seat_reserve +odoo-addon-event_seat_reserve @ git+https://github.com/OCA/event.git@refs/pull/394/head#subdirectory=setup/event_seat_reserve