From ef775df746263fd1a3b4baa97eb08c880d76618d Mon Sep 17 00:00:00 2001 From: "Adrien Widart (awt)" Date: Fri, 21 Oct 2022 11:52:41 +0000 Subject: [PATCH] [FIX] delivery: add a carrier on a delivery It is not possible for a user to add a carrier directly on a picking if the invoicing policy of that carrier is set to "Real Cost" To reproduce the issue: 1. Enable a carrier C 2. Setup a shipping method SM: - Carrier: C - Invoicing Policy: Real Cost 3. Create and confirm a SO with a product 4. Edit the related picking P: - Carrier: SM 5. Validate P Error: a Validation error is raised "The operation cannot be completed [...] Model: Sales Order Line (sale.order.line), Field: Description (name)" When validating the delivery, we try to create a new SOL with the shipping cost. We then update its description with the carrier name. However, since the carrier has been directly added on the picking, the sale order does not have that information. We should rather get this information from the delivery. OPW-2862306 closes odoo/odoo#103986 X-original-commit: 611bd008075f5b8f8080281ae877ada3076a9e7a Signed-off-by: Adrien Widart Signed-off-by: Tiffany Chang --- addons/delivery/models/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/delivery/models/stock_picking.py b/addons/delivery/models/stock_picking.py index 2b96f84b099..88a7ec41610 100644 --- a/addons/delivery/models/stock_picking.py +++ b/addons/delivery/models/stock_picking.py @@ -225,7 +225,7 @@ class StockPicking(models.Model): delivery_line[0].write({ 'price_unit': carrier_price, # remove the estimated price from the description - 'name': sale_order.carrier_id.with_context(lang=self.partner_id.lang).name, + 'name': self.carrier_id.with_context(lang=self.partner_id.lang).name, }) def open_website_url(self):