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.

36 lines
1.4 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.filtered(
  12. lambda sol: sol.product_id == bal_prod
  13. )
  14. line = lines and lines[0]
  15. if line:
  16. # Update existing line
  17. update_values = order._prepare_order_line_update_values(
  18. line, line.product_uom_qty + 1
  19. )
  20. if update_values:
  21. order._update_cart_line_values(line, update_values)
  22. else:
  23. # Create new line
  24. line_values = order._prepare_order_line_values(bal_prod.id, 1)
  25. line.sudo().create(line_values)
  26. if len(self) == 1 and self.env.context.get("open_sale_order", False):
  27. return {
  28. "type": "ir.actions.act_window",
  29. "view_mode": "form",
  30. "res_model": "sale.order",
  31. "res_id": self.id,
  32. "target": "current",
  33. }