Skip to content

Commit

Permalink
[ADD] pos_event_registration: reimplement module from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
em230418 committed Dec 3, 2024
1 parent ad7f910 commit 8064c58
Show file tree
Hide file tree
Showing 15 changed files with 747 additions and 0 deletions.
85 changes: 85 additions & 0 deletions pos_event_registration/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
========================
Register Event Attendees
========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:08590e08c3c68789632c46cdc7ca9fa7e784bbd2f83e1b5929113a77a96492e3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-it--projects--llc%2Fpos--addons-lightgray.png?logo=github
:target: https://github.com/it-projects-llc/pos-addons/tree/17.0/pos_event_registration
:alt: it-projects-llc/pos-addons

|badge1| |badge2| |badge3|

Sell Tickets via POS

**Table of contents**

.. contents::
:local:

Configuration
=============

- Open "Point of Sale" -> Products -> Products

- Choose any product or create new one

- In "Sale" tab

- Enable "Available in POS"
- Set "Category", which products will be used in POS
- Set "Linked Event"
- Set "Linked Event Ticket"

- Save

Usage
=====

- Open "Point of Sale"
- Open any "POS"
- Choose "Customer"
- Sell product with assigned event ticket
- RESULT: event registration with chosen customer is created

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/it-projects-llc/pos-addons/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 <https://github.com/it-projects-llc/pos-addons/issues/new?body=module:%20pos_event_registration%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* IT-Projects LLC

Contributors
------------

- Eugene Molotov (https://github.com/em230418)

Maintainers
-----------

This module is part of the `it-projects-llc/pos-addons <https://github.com/it-projects-llc/pos-addons/tree/17.0/pos_event_registration>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions pos_event_registration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions pos_event_registration/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Register Event Attendees",
"summary": "Process Attendees and Sell Tickets via POS",
"category": "Point of Sale",
"version": "17.0.0.1.0",
"author": "IT-Projects LLC",
"support": "[email protected]",
"website": "https://github.com/it-projects-llc/pos-addons",
"license": "LGPL-3",
"depends": [
"point_of_sale",
"event_sale",
],
"data": ["views/product_view.xml"],
}
2 changes: 2 additions & 0 deletions pos_event_registration/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_template
from . import pos_order
49 changes: 49 additions & 0 deletions pos_event_registration/models/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import logging

from odoo import api, models

_logger = logging.getLogger(__name__)


class PosOrder(models.Model):
_inherit = "pos.order"

@api.model
def _process_order(self, *args, **kw):
order_id = super()._process_order(*args, **kw)
order = self.env["pos.order"].sudo().browse(order_id)
partner = order.partner_id
Registrations = self.env["event.registration"].sudo()

event_products = order.lines.filtered("product_id.pos_event_ticket").mapped(
"product_id"
)

if not event_products:
return order_id

for line in order.lines:
product = line.product_id
if product not in event_products:
continue

ticket = product.pos_event_ticket

qty = int(line.qty)
for i in range(qty):
name = not i and partner.name or partner.name + " person " + str(i + 1)
vals = {
"event_id": ticket.event_id.id,
"partner_id": partner.id,
"event_ticket_id": product.pos_event_ticket.id,
"email": partner.email,
"name": name,
"state": "open",
}
_logger.info("Creating Attendee with vals %s", vals)
if "attendee_partner_id" in Registrations._fields:
vals["attendee_partner_id"] = partner.id

Registrations.create(vals)

return order.id
16 changes: 16 additions & 0 deletions pos_event_registration/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

pos_event = fields.Many2one("event.event", string="Linked Event")
pos_event_ticket = fields.Many2one(
"event.event.ticket",
string="Linked Event Ticket",
help="When customer buys this product in POS, he is automatically registered as attendee with given ticket", # noqa: E501
)

@api.onchange("pos_event")
def _onchange_pos_event(self):
self.update({"pos_event_ticket": False})
3 changes: 3 additions & 0 deletions pos_event_registration/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
10 changes: 10 additions & 0 deletions pos_event_registration/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- Open "Point of Sale" -> Products -> Products
- Choose any product or create new one
- In "Sale" tab

* Enable "Available in POS"
* Set "Category", which products will be used in POS
* Set "Linked Event"
* Set "Linked Event Ticket"

- Save
1 change: 1 addition & 0 deletions pos_event_registration/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Eugene Molotov (https://github.com/em230418)
1 change: 1 addition & 0 deletions pos_event_registration/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sell Tickets via POS
5 changes: 5 additions & 0 deletions pos_event_registration/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Open "Point of Sale"
- Open any "POS"
- Choose "Customer"
- Sell product with assigned event ticket
- RESULT: event registration with chosen customer is created
Loading

0 comments on commit 8064c58

Please sign in to comment.