Skip to content
Snippets Groups Projects
Commit afed7db3 authored by Touati Djamel (otd)'s avatar Touati Djamel (otd)
Browse files

[FIX] delivery: compute total amount only if a sale order exists


Steps to reproduce the bug:
- Create a delivery transfer:
- Add any product
- Select any carrier in the additional info tab
- try to validate the transfer

Problem:
An error is triggered: `ValueError: Expected singleton: sale.order()`
The `_compute_amount_total_without_delivery` function is called with an
empty recordset whereas we need to trigger it with a sale_order

opw-3164490
opw-3168878
opw-3166074

closes odoo/odoo#112069

Signed-off-by: default avatarDjamel Touati (otd) <otd@odoo.com>
parent e3900dfe
No related branches found
No related tags found
No related merge requests found
......@@ -219,9 +219,10 @@ class StockPicking(models.Model):
def send_to_shipper(self):
self.ensure_one()
res = self.carrier_id.send_shipping(self)[0]
amount_without_delivery = self.sale_id._compute_amount_total_without_delivery()
if self.carrier_id.free_over and self.sale_id and self.carrier_id._compute_currency(self.sale_id, amount_without_delivery, 'pricelist_to_company') >= self.carrier_id.amount:
res['exact_price'] = 0.0
if self.carrier_id.free_over and self.sale_id:
amount_without_delivery = self.sale_id._compute_amount_total_without_delivery()
if self.carrier_id._compute_currency(self.sale_id, amount_without_delivery, 'pricelist_to_company') >= self.carrier_id.amount:
res['exact_price'] = 0.0
self.carrier_price = res['exact_price'] * (1.0 + (self.carrier_id.margin / 100.0))
if res['tracking_number']:
previous_pickings = self.env['stock.picking']
......
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