Odoo modules related to events management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.0 KiB

  1. from odoo import models, api
  2. class EventRegistration(models.Model):
  3. _inherit = "event.registration"
  4. def action_set_done(self):
  5. super().action_set_done()
  6. for regis in self:
  7. tic_prod = regis.event_ticket_id.product_id
  8. bal_prod = tic_prod.balance_variant_id
  9. if tic_prod.is_event_deposit and bal_prod:
  10. order = regis.sale_order_id
  11. lines = order.order_line
  12. line = lines.filtered(lambda sol: sol.product_id == bal_prod, limit=1)
  13. if line:
  14. # Update existing line
  15. update_values = order._prepare_order_line_update_values(
  16. line, line.product_uom_qty + 1
  17. )
  18. if update_values:
  19. order._update_cart_line_values(line, update_values)
  20. else:
  21. # Create new line
  22. line_values = order._prepare_order_line_values(bal_prod, 1)
  23. line.sudo().create(line_values)