Skip to content

Commit

Permalink
[14.0] base_delivery_carrier_label: add check when no carrier_id assi…
Browse files Browse the repository at this point in the history
…gned and fix import mock bug
  • Loading branch information
sonhd committed Jan 19, 2022
1 parent b8a5078 commit 1300c81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions base_delivery_carrier_label/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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", []):
Expand Down
3 changes: 1 addition & 2 deletions base_delivery_carrier_label/tests/test_send.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 1300c81

Please sign in to comment.