[FIX] delivery: wrong delivery price for real cost in so
Steps to reproduce the bug:
- Install FedEx delivery
- Go to the shipping method > FedEx:
- Select Real cost and margin on rate 10%
- Create a storable Product “P1” and update its qty
- Create a SO:
- Add the product “P1”
- Click on add shipping
- Select FedEx and get the rate
- Imagine the price is $10 and with margin it's $11
- Confirm the SO and process the delivery
Probelm:
The shipping price will be $12 instead of $11 in the SO
Because the estimated price is calculated the first time with margin
and added in the picking when sending to the shipper:
https://github.com/odoo/odoo/blob/afed7db30042e2ea91cdae292dadb7b6f742e33d/addons/delivery/models/stock_picking.py#L226
Then, the delivery cost is added to the SO, but the margin is applied a
second time:
https://github.com/odoo/odoo/blob/afed7db30042e2ea91cdae292dadb7b6f742e33d/addons/delivery/models/stock_picking.py#L246
https://github.com/odoo/odoo/blob/afed7db30042e2ea91cdae292dadb7b6f742e33d/addons/delivery/models/stock_picking.py#L262
so this commit is useless:
https://github.com/odoo/odoo/commit/632767d83e0f42acc5b486bde02dd1d9c2533911
because the `_add_delivery_cost_to_so` function is called only when
sending to the shipper
opw-3184482
closes odoo/odoo#113064
X-original-commit: b8c4fcbc1cba369dce8296b800565dfd181957a4
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
@@ -213,13 +213,12 @@ 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, carrier_price)
|
||||
sale_order._create_delivery_line(self.carrier_id, self.carrier_price)
|
||||
else:
|
||||
delivery_line = delivery_lines[0]
|
||||
delivery_line[0].write({
|
||||
'price_unit': carrier_price,
|
||||
'price_unit': self.carrier_price,
|
||||
# remove the estimated price from the description
|
||||
'name': self.carrier_id.with_context(lang=self.partner_id.lang).name,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user