Skip to content
Snippets Groups Projects
Commit 756c5b49 authored by Victor Feyens's avatar Victor Feyens
Browse files

[REF] event_sale: correctly compute discount for event tickets

Discount wasn't computed the same way in backend sale flows and e-commerce flows.
Now the pricelist discount policy will be considered in the core logic of
event_sale.

Part-of: odoo/odoo#82374
parent 6e6d9f3b
Branches
Tags
No related merge requests found
......@@ -53,8 +53,6 @@ class EventTemplateTicket(models.Model):
def _compute_price_reduce(self):
for ticket in self:
product = ticket.product_id
# TODO drop price field usage
# and ideally remove this whole price_reduce logic
# seems strange to not apply pricelist logic but still use pricelist discount...
discount = (
product.lst_price - product._get_contextual_price()
......
......@@ -134,14 +134,9 @@ class SaleOrderLine(models.Model):
super(SaleOrderLine, self-event_lines)._compute_price_unit()
for line in event_lines:
if not line.product_id or line._origin.product_id != line.product_id:
# Note: this also computes the price for new lines :)
super(SaleOrderLine, line)._compute_price_unit()
@api.depends('event_ticket_id')
def _compute_discount(self):
"""Do not compute the discount on event lines, it's always included in the price."""
event_lines = self.filtered('event_ticket_id')
super(SaleOrderLine, self-event_lines)._compute_discount()
@api.depends('event_ticket_id')
def _compute_name(self):
"""Override to add the compute dependency.
......@@ -173,12 +168,13 @@ class SaleOrderLine(models.Model):
def _get_display_price(self):
if self.event_ticket_id and self.event_id:
# FIXME this is strange
# price_reduce is the price after discount
# shouldn't we leave the discount computation to sale
# and use the non reduced price here (aka price field)
return self.event_ticket_id.with_context(
event_ticket = self.event_ticket_id.with_context(
pricelist=self.order_id.pricelist_id.id,
uom=self.product_uom.id).price_reduce
uom=self.product_uom.id
)
if self.order_id.pricelist_id.discount_policy == 'with_discount':
return event_ticket.price_reduce
else:
return event_ticket.price
else:
return super()._get_display_price()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment