-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] event_ticket_limit: add event ticket limiting module
Added event ticket limiting module allows users to control how many tickets a Users can book in a single registration.
- Loading branch information
Showing
6 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Event Ticket Limit", | ||
"summary": """ | ||
Module for limiting the number of tickets per registration | ||
""", | ||
"description": """ | ||
Module for limiting the number of tickets per registration | ||
""", | ||
"author": "Odoo", | ||
"website": "https://www.odoo.com", | ||
"category": "Event/ Event Ticket Limit", | ||
"version": "0.1", | ||
"installable": True, | ||
"auto_install": True, | ||
"depends": ["base_setup", "event", "website_event"], | ||
"data": [ | ||
"views/event_tickets_views.xml", | ||
"views/event_registration_website_view.xml", | ||
], | ||
"license": "AGPL-3", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import event_ticket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class EventTicketInherit(models.Model): | ||
_inherit = "event.event.ticket" | ||
|
||
tickets_per_registration = fields.Integer( | ||
string="Tickets per Registration", | ||
help="Number of tickets per registration. 0 means unlimited.", | ||
) |
16 changes: 16 additions & 0 deletions
16
event_ticket_limit/views/event_registration_website_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<template id="modal_ticket_registration" name="modal_ticket_registration" inherit_id="website_event.modal_ticket_registration"> | ||
<xpath expr="//select[@class='w-auto form-select']" position="replace"> | ||
<select t-if="not ticket.is_expired and ticket.sale_available" t-attf-name="nb_register-#{ticket.id}" class="w-auto form-select"> | ||
<t t-set="seats_max_ticket" t-value="(not ticket.seats_limited or ticket.seats_available > 9) and 10 or ticket.seats_available + 1"/> | ||
<t t-set="seats_max_event" t-value="(not event.seats_limited or event.seats_available > 9) and 10 or event.seats_available + 1"/> | ||
<t t-set="seats_max_registration" t-value="ticket.tickets_per_registration+1 if ticket.tickets_per_registration else 10"/> | ||
<t t-set="seats_max" t-value="min(seats_max_ticket, seats_max_event, seats_max_registration)"/> | ||
<t t-foreach="range(0, seats_max)" t-as="nb"> | ||
<option t-out="nb" t-att-selected="len(ticket) == 0 and nb == 0 and 'selected'"/> | ||
</t> | ||
</select> | ||
</xpath> | ||
</template> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="event_event_ticket_view_tree_from_event_inherit_module_name" model="ir.ui.view"> | ||
<field name="name">event.event.ticket.view.list.inherit</field> | ||
<field name="model">event.event.ticket</field> | ||
<field name="inherit_id" ref="event.event_event_ticket_view_tree_from_event"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//list" position="inside"> | ||
<field name="tickets_per_registration" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |