|
|
@ -11,8 +11,10 @@ class EventRegistration(models.Model): |
|
|
|
bal_prod = tic_prod.balance_variant_id |
|
|
|
if tic_prod.is_event_deposit and bal_prod: |
|
|
|
order = regis.sale_order_id |
|
|
|
lines = order.order_line |
|
|
|
line = lines.filtered(lambda sol: sol.product_id == bal_prod, limit=1) |
|
|
|
lines = order.order_line.filtered( |
|
|
|
lambda sol: sol.product_id == bal_prod |
|
|
|
) |
|
|
|
line = lines and lines[0] |
|
|
|
if line: |
|
|
|
# Update existing line |
|
|
|
update_values = order._prepare_order_line_update_values( |
|
|
@ -22,5 +24,13 @@ class EventRegistration(models.Model): |
|
|
|
order._update_cart_line_values(line, update_values) |
|
|
|
else: |
|
|
|
# Create new line |
|
|
|
line_values = order._prepare_order_line_values(bal_prod, 1) |
|
|
|
line_values = order._prepare_order_line_values(bal_prod.id, 1) |
|
|
|
line.sudo().create(line_values) |
|
|
|
if len(self) == 1 and self.env.context.get("open_sale_order", False): |
|
|
|
return { |
|
|
|
"type": "ir.actions.act_window", |
|
|
|
"view_mode": "form", |
|
|
|
"res_model": "sale.order", |
|
|
|
"res_id": self.id, |
|
|
|
"target": "current", |
|
|
|
} |