diff --git a/base_delivery_carrier_label/models/delivery_carrier.py b/base_delivery_carrier_label/models/delivery_carrier.py index 35ee778d13..db22be9b5f 100644 --- a/base_delivery_carrier_label/models/delivery_carrier.py +++ b/base_delivery_carrier_label/models/delivery_carrier.py @@ -29,7 +29,7 @@ def default_options(self): def send_shipping(self, pickings): """Handle labels and if we have them. Expected format is {'labels': [{}, ...]} The dicts are input for stock.picking#attach_label""" - result = super().send_shipping(pickings) + result = None # We could want to generate labels calling a method that does not depend # on one specific delivery_type. # For instance, if we want to generate a default label in case there are not @@ -38,7 +38,9 @@ def send_shipping(self, pickings): # or at the contrary, we could call a common method for multiple delivery_type # for instance, in delivery_roulier, the same method is always called for any # carrier implemented in roulier lib. - if result is None: + if pickings.carrier_id: + result = super().send_shipping(pickings) + if not result: result = self.alternative_send_shipping(pickings) for result_dict, picking in zip(result, pickings): for label in result_dict.get("labels", []): diff --git a/base_delivery_carrier_label/tests/test_send.py b/base_delivery_carrier_label/tests/test_send.py index 5b30145085..24904d3005 100644 --- a/base_delivery_carrier_label/tests/test_send.py +++ b/base_delivery_carrier_label/tests/test_send.py @@ -1,8 +1,7 @@ # Copyright 2020 Hunki Enterprises BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import base64 - -import mock +from unittest import mock from odoo.tests.common import Form, TransactionCase