From 6159960186211a1a1981ef54296dc67a53f51e0f Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Thu, 8 Jun 2023 12:58:48 +0200 Subject: [PATCH] [IMP] delivery_roulier : allow to easily by pass the tracking url per pack for a carrier if it does not handle it --- delivery_roulier/models/stock_picking.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/delivery_roulier/models/stock_picking.py b/delivery_roulier/models/stock_picking.py index a4fd28811e..de7c472db2 100644 --- a/delivery_roulier/models/stock_picking.py +++ b/delivery_roulier/models/stock_picking.py @@ -60,6 +60,10 @@ def _get_to_address(self): def _cancel_shipment(self): pass + @implemented_by_carrier + def _support_multi_tracking(self): + pass + # End of API. # Implementations for base_delivery_carrier_label @@ -258,6 +262,12 @@ def _roulier_get_service(self, account, package=None): } return service + def _roulier_support_multi_tracking(self): + # By default roulier carrier may have one tracking ref per pack. + # override this method for your carrier if you always have a unique + # tracking per picking + return True + def open_website_url(self): """Open tracking page. @@ -271,8 +281,11 @@ def open_website_url(self): packages = self.package_ids if len(packages) == 0: raise UserError(_("No packages found for this picking")) - elif len(packages) == 1: - return packages.open_website_url() # shortpath + else: + if not self._support_multi_tracking(): + packages = packages[0] + if len(packages) == 1: + return packages.open_website_url() # shortpath # display a list of pickings xmlid = "stock.action_package_view"