diff --git a/setup/website_event_sale_seat_reserve/odoo/addons/website_event_sale_seat_reserve b/setup/website_event_sale_seat_reserve/odoo/addons/website_event_sale_seat_reserve new file mode 120000 index 000000000..4ede6e82a --- /dev/null +++ b/setup/website_event_sale_seat_reserve/odoo/addons/website_event_sale_seat_reserve @@ -0,0 +1 @@ +../../../../website_event_sale_seat_reserve \ No newline at end of file diff --git a/setup/website_event_sale_seat_reserve/setup.py b/setup/website_event_sale_seat_reserve/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/website_event_sale_seat_reserve/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..8552a882a --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-event_sale_seat_reserve @ git+https://github.com/OCA/event.git@refs/pull/395/head#subdirectory=event_sale_seat_reserve diff --git a/website_event_sale_seat_reserve/README.rst b/website_event_sale_seat_reserve/README.rst new file mode 100644 index 000000000..becb88553 --- /dev/null +++ b/website_event_sale_seat_reserve/README.rst @@ -0,0 +1,78 @@ +=============================== +Website Event Sale Seat Reserve +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:78323ee06ed8331afd0ba7aac22e975b5057d12b6fa4dc6c8690505562ebf4c5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github + :target: https://github.com/OCA/event/tree/16.0/website_event_sale_seat_reserve + :alt: OCA/event +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/event-16-0/event-16-0-website_event_sale_seat_reserve + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to make a pre-reserve on registrations after creating a draft order from website. +If a customer add a registration to his cart, the registration will create a draft order and will be +automatically pre-reserved. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Italo LOPES + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/event `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_event_sale_seat_reserve/__init__.py b/website_event_sale_seat_reserve/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/website_event_sale_seat_reserve/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/website_event_sale_seat_reserve/__manifest__.py b/website_event_sale_seat_reserve/__manifest__.py new file mode 100644 index 000000000..da93333d3 --- /dev/null +++ b/website_event_sale_seat_reserve/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). +{ + "name": "Website Event Sale Seat Reserve", + "version": "16.0.1.0.0", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/event", + "category": "Marketing", + "summary": "Allow pre-reserve registrations on website sales", + "depends": ["website_event_sale", "event_sale_seat_reserve"], + "installable": True, + "auto_install": True, + "assets": { + "web.assets_tests": [ + "website_event_sale_seat_reserve/static/tests/**/*", + ], + }, +} diff --git a/website_event_sale_seat_reserve/models/__init__.py b/website_event_sale_seat_reserve/models/__init__.py new file mode 100644 index 000000000..6f6a9dff3 --- /dev/null +++ b/website_event_sale_seat_reserve/models/__init__.py @@ -0,0 +1 @@ +from . import event_registration diff --git a/website_event_sale_seat_reserve/models/event_registration.py b/website_event_sale_seat_reserve/models/event_registration.py new file mode 100644 index 000000000..5b1fab7c3 --- /dev/null +++ b/website_event_sale_seat_reserve/models/event_registration.py @@ -0,0 +1,22 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). + +from odoo import api, models + + +class EventRegistration(models.Model): + _inherit = "event.registration" + + def _auto_reserve_registrations(self): + to_reserve = self.filtered( + lambda rec: ( + rec.state == "draft" and rec.sale_order_line_id and rec.visitor_id + ) + ) + to_reserve.action_set_reserved() + + @api.model_create_multi + def create(self, vals_list): + registrations = super().create(vals_list) + registrations._auto_reserve_registrations() + return registrations diff --git a/website_event_sale_seat_reserve/readme/CONTRIBUTORS.rst b/website_event_sale_seat_reserve/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..04b04faf0 --- /dev/null +++ b/website_event_sale_seat_reserve/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Italo LOPES diff --git a/website_event_sale_seat_reserve/readme/DESCRIPTION.rst b/website_event_sale_seat_reserve/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b643ff7b5 --- /dev/null +++ b/website_event_sale_seat_reserve/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module allows to make a pre-reserve on registrations after creating a draft order from website. +If a customer add a registration to his cart, the registration will create a draft order and will be +automatically pre-reserved. diff --git a/website_event_sale_seat_reserve/static/description/icon.png b/website_event_sale_seat_reserve/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/website_event_sale_seat_reserve/static/description/icon.png differ diff --git a/website_event_sale_seat_reserve/static/description/index.html b/website_event_sale_seat_reserve/static/description/index.html new file mode 100644 index 000000000..f69188762 --- /dev/null +++ b/website_event_sale_seat_reserve/static/description/index.html @@ -0,0 +1,422 @@ + + + + + +Website Event Sale Seat Reserve + + + +
+

Website Event Sale Seat Reserve

+ + +

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runboat

+

This module allows to make a pre-reserve on registrations after creating a draft order from website. +If a customer add a registration to his cart, the registration will create a draft order and will be +automatically pre-reserved.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/event project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/website_event_sale_seat_reserve/static/tests/tours/website_event_sale_seat_reserve.js b/website_event_sale_seat_reserve/static/tests/tours/website_event_sale_seat_reserve.js new file mode 100644 index 000000000..55838b6f1 --- /dev/null +++ b/website_event_sale_seat_reserve/static/tests/tours/website_event_sale_seat_reserve.js @@ -0,0 +1,45 @@ +odoo.define("website_event_sale_seat_reserve", function (require) { + "use strict"; + + var tour = require("web_tour.tour"); + + tour.register( + "tour_website_event_sale_seat_reserve", + { + test: true, + url: "/event", + }, + [ + { + content: "Go to the `Events` page", + trigger: 'a[href*="/event"]:contains("Business workshops"):first', + }, + { + content: "Select 1 unit of `Standard` ticket type", + extra_trigger: + '#wrap:not(:has(a[href*="/event"]:contains("Business workshops")))', + trigger: "select:eq(0)", + run: "text 1", + }, + { + content: "Click on `Order Now` button", + extra_trigger: "select:eq(1):has(option:contains(2):propSelected)", + trigger: '.btn-primary:contains("Register")', + }, + { + content: "Fill attendees details", + trigger: 'form[id="attendee_registration"] .btn:contains("Continue")', + run: function () { + $("input[name='1-name']").val("Att1"); + $("input[name='1-phone']").val("111 111"); + $("input[name='1-email']").val("att1@example.com"); + }, + }, + { + content: "Validate attendees details", + extra_trigger: "input[name='1-name']", + trigger: 'button:contains("Continue")', + }, + ] + ); +}); diff --git a/website_event_sale_seat_reserve/tests/__init__.py b/website_event_sale_seat_reserve/tests/__init__.py new file mode 100644 index 000000000..365face63 --- /dev/null +++ b/website_event_sale_seat_reserve/tests/__init__.py @@ -0,0 +1 @@ +from . import website_event_sale_seat_reserve diff --git a/website_event_sale_seat_reserve/tests/website_event_sale_seat_reserve.py b/website_event_sale_seat_reserve/tests/website_event_sale_seat_reserve.py new file mode 100644 index 000000000..3311ee05d --- /dev/null +++ b/website_event_sale_seat_reserve/tests/website_event_sale_seat_reserve.py @@ -0,0 +1,51 @@ +# Copyright 2024 Camptocamp (http://www.camptocamp.com). +# @author Italo LOPES +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import HttpCase, tagged + + +@tagged("post_install", "-at_install") +class TestWebsiteEventSaleSeatReserve(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + # Event + cls.event = cls.env.ref("event.event_4") + cls.event_ticket = cls.env.ref("event.event_4_ticket_0") + cls.event_product = cls.env.ref("event_sale.product_product_event") + # Websites + cls.website_1 = cls.env.ref("website.default_website") + # Orders + cls.partner = cls.env.ref("base.res_partner_1") + cls.partner2 = cls.env.ref("base.res_partner_2") + cls.order_1 = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "team_id": cls.env.ref("sales_team.salesteam_website_sales").id, + "payment_term_id": cls.env.ref( + "account.account_payment_term_end_following_month" + ).id, + } + ) + + cls.env["sale.order.line"].create( + { + "product_id": cls.event_product.id, + "price_unit": 30, + "order_id": cls.order_1.id, + "event_id": cls.event.id, + "event_ticket_id": cls.event_ticket.id, + } + ) + + def test_add_event_to_cart(self): + existing_orders = self.env["sale.order"].search([]) + # In frontend, create an order + self.start_tour( + "/event", "tour_website_event_sale_seat_reserve", login="portal" + ) + created_order = self.env["sale.order"].search( + [("id", "not in", existing_orders.ids)] + ) + self.assertEqual(created_order.state, "draft")