From ca75c23ccddeec1e7313683d2219a84b4de43c03 Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Thu, 24 Nov 2022 08:00:48 +0000 Subject: [PATCH] [FIX] stock: print delivery address for outgoing picking or dropship The delivery slip of an outgoing picking prints the warehouse address instead of the delivery address (which should be displayed as it may be different from the customer address) Steps to reproduce: 1. Install Contacts and Inventory 2. Open Contacts and add a delivery address named "delivery" to contact Azure Interior 3. Go to Inventory > Operations > Transfers 4. Create a new transfer with: - Contact: Azure Interior, delivery - Operation Type: San Fransisco: Delivery Orders - Product: Large Cabinet 5. Save the transfer and print the Delivery Slip 6. The warehouse address is displayed and there is no info about the delivery address Solution: Add a method to know if we should print the delivery address. We should print it if the picking has a delivery address and it is of type outgoing (or if it's a dropship) Problem: Printing the delivery address when the package partner is different from the picking partner is wrong because the delivery address might be different from the customer address opw-3064203 closes odoo/odoo#107355 X-original-commit: ec929f787f629940cd38a4ed25e5012335e2483d Signed-off-by: Tiffany Chang Signed-off-by: Guillaume Merlin (megu) --- addons/stock/models/stock_picking.py | 8 ++++++++ addons/stock/report/report_deliveryslip.xml | 4 ++-- addons/stock_dropshipping/models/stock.py | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index ecb8f6262da..362867fee0f 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -821,6 +821,14 @@ class Picking(models.Model): self.write({'printed': True}) return self.env.ref('stock.action_report_picking').report_action(self) + def should_print_delivery_address(self): + self.ensure_one() + return self.move_ids_without_package and self.move_ids_without_package[0].partner_id and self._is_to_external_location() + + def _is_to_external_location(self): + self.ensure_one() + return self.picking_type_code == 'outgoing' + def action_confirm(self): self._check_company() self.mapped('package_level_ids').filtered(lambda pl: pl.state == 'draft' and not pl.move_ids)._generate_moves() diff --git a/addons/stock/report/report_deliveryslip.xml b/addons/stock/report/report_deliveryslip.xml index b81471bd2a4..801148c98c1 100644 --- a/addons/stock/report/report_deliveryslip.xml +++ b/addons/stock/report/report_deliveryslip.xml @@ -9,13 +9,13 @@
+ t-if="o.should_print_delivery_address()"> Delivery Address:
+ t-elif="o.picking_type_id.code != 'internal' and o.picking_type_id.warehouse_id.partner_id"> Warehouse Address:
diff --git a/addons/stock_dropshipping/models/stock.py b/addons/stock_dropshipping/models/stock.py index a0382350d5c..f725d1e9251 100644 --- a/addons/stock_dropshipping/models/stock.py +++ b/addons/stock_dropshipping/models/stock.py @@ -35,6 +35,9 @@ class StockPicking(models.Model): for picking in self: picking.is_dropship = picking.location_dest_id.usage == 'customer' and picking.location_id.usage == 'supplier' + def _is_to_external_location(self): + self.ensure_one() + return super()._is_to_external_location() or self.is_dropship class StockPickingType(models.Model): _inherit = 'stock.picking.type'