[FIX] event_sale: get the right number of registrations

Steps:
- Create a new event.
- Choose any template (training, conference,...).
- Create new registration ticket for this event.
- Create a new quotation.
- Add 2 lines for "Event registration" product, and select each time the event and ticket created above.
- Click on "Confirm".

Issue:
4 registrations lines are created and 3 attendees.

Reason:
In ``RegistrationEditor.default_get()``, we match each sale order line with existing registrations in the sale order having
the same ``event_ticket_id`` without assuming we can have multiple sale order lines with the same ``event_ticket_id``. That
leads to [number_of_sol] * [number_of_ticket] registrations. To solve it, we just add an additional check for the
``sale_order_line_id`` to have a perfect match.

opw-3495415

closes odoo/odoo#138242

X-original-commit: 926ab300650eda02aefa728fa32b44831c49dfb3
Signed-off-by: Jérémy Hennecart (jeh) <jeh@odoo.com>
This commit is contained in:
Eteil Djoumatchoua(etdj)
2023-10-10 15:42:57 +00:00
committed by Eteil Djoumatchoua(etdj) etdj@odoo.com
parent 7500db787c
commit 41bd821f82
@@ -58,7 +58,7 @@ class RegistrationEditor(models.TransientModel):
attendee_list = []
for so_line in [l for l in sale_order.order_line if l.event_ticket_id]:
existing_registrations = [r for r in registrations if r.event_ticket_id == so_line.event_ticket_id]
existing_registrations = [r for r in registrations if r.event_ticket_id == so_line.event_ticket_id and r.sale_order_line_id == so_line]
for reg in existing_registrations:
attendee_list.append([0, 0, {
'event_id': reg.event_id.id,