Skip to content
Snippets Groups Projects
Commit 621dac80 authored by Goffin Simon's avatar Goffin Simon
Browse files

[FIX] delivery: Delivery Order Adding Freight Cost W/O Markup


Steps to reproduce the bug:

- Let's consider a delivery method DM with fixed price of 10€ and a margin of 20%
- Let's consider a storable product P
- Create a SO for P and get the rate (12€) but don't add it on the SO
- Confirm the SO and process the delivery

Bug:

A SO line was created for the freight cost without the margin. So it was 10€
instead of 12€.

opw:2144894

closes odoo/odoo#43206

X-original-commit: f6ce45fc52da449df240bce467319e6110012e4c
Signed-off-by: default avatarSimon Goffin (sig) <sig@openerp.com>
parent b3c1411e
No related branches found
No related tags found
No related merge requests found
......@@ -170,12 +170,13 @@ class StockPicking(models.Model):
sale_order = self.sale_id
if sale_order and self.carrier_id.invoice_policy == 'real' and self.carrier_price:
delivery_lines = sale_order.order_line.filtered(lambda l: l.is_delivery and l.currency_id.is_zero(l.price_unit) and l.product_id == self.carrier_id.product_id)
carrier_price = self.carrier_price * (1.0 + (float(self.carrier_id.margin) / 100.0))
if not delivery_lines:
sale_order._create_delivery_line(self.carrier_id, self.carrier_price)
sale_order._create_delivery_line(self.carrier_id, carrier_price)
else:
delivery_line = delivery_lines[0]
delivery_line[0].write({
'price_unit': self.carrier_price,
'price_unit': carrier_price,
# remove the estimated price from the description
'name': sale_order.carrier_id.with_context(lang=self.partner_id.lang).name,
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment