-
- Downloads
[FIX] event_sale: recompute seats on SO deletion
When deleting a SO with an event ticket, the number of attendees becomes incorrect To reproduce the error: 1. In Settings, enable "Tickets" 2. On website, register an attendee to event E 3. In module Events, open E Error: The number of attendees (X) is incorrect. If the user clicks on it, there are X-1 attendees: the one added on step 2 has been deleted but the number is not updated When deleting a SO or a SO line, the associated registration is deleted: https://github.com/odoo/odoo/blob/3fd3fc5f782f1422f578ad38e3fad444130273a8/addons/event_sale/models/event.py#L197-L198 This is the problem: it won't trigger the `compute` methods. In the case above, this method won't be called: https://github.com/odoo/odoo/blob/72ce1b867dc81672e6a73a586542b20216388a05/addons/event/models/event.py#L176 So the number of seats won't be updated This fix suggests deleting the registrations from the ORM in order to trigger the `compute` methods. Note: Writing the tests revealed another problem. When deleting the SO, if a wizard `registration.editor` exists and is linked to the SO, the deletion will trigger an SQL constraint. This is the reason why the `ondelete` has been added to the field `sale_order_id` OPW-2452760 closes odoo/odoo#72253 Signed-off-by:Thibault Delavallee (tde) <tde@openerp.com>
Showing
- addons/event_sale/models/sale_order.py 11 additions, 0 deletionsaddons/event_sale/models/sale_order.py
- addons/event_sale/tests/test_event_sale.py 31 additions, 7 deletionsaddons/event_sale/tests/test_event_sale.py
- addons/event_sale/wizard/event_edit_registration.py 1 addition, 1 deletionaddons/event_sale/wizard/event_edit_registration.py
Please register or sign in to comment