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
36 lines
1.4 KiB
from odoo import models, api
|
|
|
|
|
|
class EventRegistration(models.Model):
|
|
_inherit = "event.registration"
|
|
|
|
def action_set_done(self):
|
|
super().action_set_done()
|
|
for regis in self:
|
|
tic_prod = regis.event_ticket_id.product_id
|
|
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.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(
|
|
line, line.product_uom_qty + 1
|
|
)
|
|
if update_values:
|
|
order._update_cart_line_values(line, update_values)
|
|
else:
|
|
# Create new line
|
|
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",
|
|
}
|