We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Weight based rates not working as expected
### What I'm trying to achieve
…
Hi there 😃 I think there is a bug when setting up shipping methods. 
### Steps to reproduce the problem
1. Setup a "Weight Based Rate" and check the "There are no value limits" checkbox.
2. Go to the storefront checkout and see that the shipping method is not shown.

### What I expected to happen
I would expect "DHL Express" to show up when the "no value limits" is enabled instead of giving me an empty "availableShippingMethods" list?

### Screenshots
--- WITH "no value limits" DISABLED ---

![image](https://user-images.githubusercontent.com/33222461/108908864-bc489500-761b-11eb-9693-a7f086266cc4.png)

![image](https://user-images.githubusercontent.com/33222461/108908700-86a3ac00-761b-11eb-97df-d22af6885530.png)

--- WITH "no value limits" ENABLED ---

![image](https://user-images.githubusercontent.com/33222461/108909031-ebf79d00-761b-11eb-915f-250f74699bcf.png)

![image](https://user-images.githubusercontent.com/33222461/108908978-dbdfbd80-761b-11eb-8fec-70dc6ef2e5d7.png)


**System information**
Operating system: Windows 10 (WSL2)
Saleor/Saleor-storefront/Saleor-Dashboard version: 2.11

Apologies if I'm misunderstanding something or if this has already been raised - couldn't find it as an issue in any of the repos.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `saleor/shipping/models.py`
Content:
```
1 from typing import TYPE_CHECKING, Union
2 
3 from django.conf import settings
4 from django.db import models
5 from django.db.models import Q
6 from django_countries.fields import CountryField
7 from django_measurement.models import MeasurementField
8 from django_prices.models import MoneyField
9 from measurement.measures import Weight
10 from prices import Money, MoneyRange
11 
12 from ..core.permissions import ShippingPermissions
13 from ..core.utils.translations import TranslationProxy
14 from ..core.weight import (
15     WeightUnits,
16     convert_weight,
17     get_default_weight_unit,
18     zero_weight,
19 )
20 from . import ShippingMethodType
21 
22 if TYPE_CHECKING:
23     # flake8: noqa
24     from ..checkout.models import Checkout
25     from ..order.models import Order
26 
27 
28 def _applicable_weight_based_methods(weight, qs):
29     """Return weight based shipping methods that are applicable for the total weight."""
30     qs = qs.weight_based()
31     min_weight_matched = Q(minimum_order_weight__lte=weight)
32     no_weight_limit = Q(maximum_order_weight__isnull=True)
33     max_weight_matched = Q(maximum_order_weight__gte=weight)
34     return qs.filter(min_weight_matched & (no_weight_limit | max_weight_matched))
35 
36 
37 def _applicable_price_based_methods(price: Money, qs):
38     """Return price based shipping methods that are applicable for the given total."""
39     qs = qs.price_based()
40     min_price_matched = Q(minimum_order_price_amount__lte=price.amount)
41     no_price_limit = Q(maximum_order_price_amount__isnull=True)
42     max_price_matched = Q(maximum_order_price_amount__gte=price.amount)
43     return qs.filter(min_price_matched & (no_price_limit | max_price_matched))
44 
45 
46 def _get_weight_type_display(min_weight, max_weight):
47     default_unit = get_default_weight_unit()
48 
49     if min_weight.unit != default_unit:
50         min_weight = convert_weight(min_weight, default_unit)
51     if max_weight and max_weight.unit != default_unit:
52         max_weight = convert_weight(max_weight, default_unit)
53 
54     if max_weight is None:
55         return ("%(min_weight)s and up" % {"min_weight": min_weight},)
56     return "%(min_weight)s to %(max_weight)s" % {
57         "min_weight": min_weight,
58         "max_weight": max_weight,
59     }
60 
61 
62 class ShippingZone(models.Model):
63     name = models.CharField(max_length=100)
64     countries = CountryField(multiple=True, default=[], blank=True)
65     default = models.BooleanField(default=False)
66 
67     def __str__(self):
68         return self.name
69 
70     @property
71     def price_range(self):
72         prices = [
73             shipping_method.get_total()
74             for shipping_method in self.shipping_methods.all()
75         ]
76         if prices:
77             return MoneyRange(min(prices), max(prices))
78         return None
79 
80     class Meta:
81         permissions = (
82             (ShippingPermissions.MANAGE_SHIPPING.codename, "Manage shipping."),
83         )
84 
85 
86 class ShippingMethodQueryset(models.QuerySet):
87     def price_based(self):
88         return self.filter(type=ShippingMethodType.PRICE_BASED)
89 
90     def weight_based(self):
91         return self.filter(type=ShippingMethodType.WEIGHT_BASED)
92 
93     def applicable_shipping_methods(self, price: Money, weight, country_code):
94         """Return the ShippingMethods that can be used on an order with shipment.
95 
96         It is based on the given country code, and by shipping methods that are
97         applicable to the given price & weight total.
98         """
99         qs = self.filter(
100             shipping_zone__countries__contains=country_code, currency=price.currency,
101         )
102         qs = qs.prefetch_related("shipping_zone").order_by("price_amount")
103         price_based_methods = _applicable_price_based_methods(price, qs)
104         weight_based_methods = _applicable_weight_based_methods(weight, qs)
105         return price_based_methods | weight_based_methods
106 
107     def applicable_shipping_methods_for_instance(
108         self, instance: Union["Checkout", "Order"], price: Money, country_code=None
109     ):
110         if not instance.is_shipping_required():
111             return None
112         if not instance.shipping_address:
113             return None
114 
115         return self.applicable_shipping_methods(
116             price=price,
117             weight=instance.get_total_weight(),
118             country_code=country_code or instance.shipping_address.country.code,
119         )
120 
121 
122 class ShippingMethod(models.Model):
123     name = models.CharField(max_length=100)
124     type = models.CharField(max_length=30, choices=ShippingMethodType.CHOICES)
125     currency = models.CharField(
126         max_length=settings.DEFAULT_CURRENCY_CODE_LENGTH,
127         default=settings.DEFAULT_CURRENCY,
128     )
129     price_amount = models.DecimalField(
130         max_digits=settings.DEFAULT_MAX_DIGITS,
131         decimal_places=settings.DEFAULT_DECIMAL_PLACES,
132         default=0,
133     )
134     price = MoneyField(amount_field="price_amount", currency_field="currency")
135     shipping_zone = models.ForeignKey(
136         ShippingZone, related_name="shipping_methods", on_delete=models.CASCADE
137     )
138 
139     minimum_order_price_amount = models.DecimalField(
140         max_digits=settings.DEFAULT_MAX_DIGITS,
141         decimal_places=settings.DEFAULT_DECIMAL_PLACES,
142         default=0,
143         blank=True,
144         null=True,
145     )
146     minimum_order_price = MoneyField(
147         amount_field="minimum_order_price_amount", currency_field="currency"
148     )
149 
150     maximum_order_price_amount = models.DecimalField(
151         max_digits=settings.DEFAULT_MAX_DIGITS,
152         decimal_places=settings.DEFAULT_DECIMAL_PLACES,
153         blank=True,
154         null=True,
155     )
156     maximum_order_price = MoneyField(
157         amount_field="maximum_order_price_amount", currency_field="currency"
158     )
159 
160     minimum_order_weight = MeasurementField(
161         measurement=Weight,
162         unit_choices=WeightUnits.CHOICES,
163         default=zero_weight,
164         blank=True,
165         null=True,
166     )
167     maximum_order_weight = MeasurementField(
168         measurement=Weight, unit_choices=WeightUnits.CHOICES, blank=True, null=True
169     )
170 
171     objects = ShippingMethodQueryset.as_manager()
172     translated = TranslationProxy()
173 
174     class Meta:
175         ordering = ("pk",)
176 
177     def __str__(self):
178         return self.name
179 
180     def __repr__(self):
181         if self.type == ShippingMethodType.PRICE_BASED:
182             minimum = "%s%s" % (
183                 self.minimum_order_price.amount,
184                 self.minimum_order_price.currency,
185             )
186             max_price = self.maximum_order_price
187             maximum = (
188                 "%s%s" % (max_price.amount, max_price.currency)
189                 if max_price
190                 else "no limit"
191             )
192             return "ShippingMethod(type=%s min=%s, max=%s)" % (
193                 self.type,
194                 minimum,
195                 maximum,
196             )
197         return "ShippingMethod(type=%s weight_range=(%s)" % (
198             self.type,
199             _get_weight_type_display(
200                 self.minimum_order_weight, self.maximum_order_weight
201             ),
202         )
203 
204     def get_total(self):
205         return self.price
206 
207 
208 class ShippingMethodTranslation(models.Model):
209     language_code = models.CharField(max_length=10)
210     name = models.CharField(max_length=255, null=True, blank=True)
211     shipping_method = models.ForeignKey(
212         ShippingMethod, related_name="translations", on_delete=models.CASCADE
213     )
214 
215     class Meta:
216         unique_together = (("language_code", "shipping_method"),)
217
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/saleor/shipping/models.py b/saleor/shipping/models.py
--- a/saleor/shipping/models.py
+++ b/saleor/shipping/models.py
@@ -28,10 +28,13 @@
 def _applicable_weight_based_methods(weight, qs):
     """Return weight based shipping methods that are applicable for the total weight."""
     qs = qs.weight_based()
-    min_weight_matched = Q(minimum_order_weight__lte=weight)
-    no_weight_limit = Q(maximum_order_weight__isnull=True)
-    max_weight_matched = Q(maximum_order_weight__gte=weight)
-    return qs.filter(min_weight_matched & (no_weight_limit | max_weight_matched))
+    min_weight_matched = Q(minimum_order_weight__lte=weight) | Q(
+        minimum_order_weight__isnull=True
+    )
+    max_weight_matched = Q(maximum_order_weight__gte=weight) | Q(
+        maximum_order_weight__isnull=True
+    )
+    return qs.filter(min_weight_matched & max_weight_matched)
 
 
 def _applicable_price_based_methods(price: Money, qs):

{"golden_diff": "diff --git a/saleor/shipping/models.py b/saleor/shipping/models.py\n--- a/saleor/shipping/models.py\n+++ b/saleor/shipping/models.py\n@@ -28,10 +28,13 @@\n def _applicable_weight_based_methods(weight, qs):\n     \"\"\"Return weight based shipping methods that are applicable for the total weight.\"\"\"\n     qs = qs.weight_based()\n-    min_weight_matched = Q(minimum_order_weight__lte=weight)\n-    no_weight_limit = Q(maximum_order_weight__isnull=True)\n-    max_weight_matched = Q(maximum_order_weight__gte=weight)\n-    return qs.filter(min_weight_matched & (no_weight_limit | max_weight_matched))\n+    min_weight_matched = Q(minimum_order_weight__lte=weight) | Q(\n+        minimum_order_weight__isnull=True\n+    )\n+    max_weight_matched = Q(maximum_order_weight__gte=weight) | Q(\n+        maximum_order_weight__isnull=True\n+    )\n+    return qs.filter(min_weight_matched & max_weight_matched)\n \n \n def _applicable_price_based_methods(price: Money, qs):\n", "issue": "Weight based rates not working as expected\n### What I'm trying to achieve\r\n\u2026\r\nHi there \ud83d\ude03 I think there is a bug when setting up shipping methods. \r\n### Steps to reproduce the problem\r\n1. Setup a \"Weight Based Rate\" and check the \"There are no value limits\" checkbox.\r\n2. Go to the storefront checkout and see that the shipping method is not shown.\r\n\r\n### What I expected to happen\r\nI would expect \"DHL Express\" to show up when the \"no value limits\" is enabled instead of giving me an empty \"availableShippingMethods\" list?\r\n\r\n### Screenshots\r\n--- WITH \"no value limits\" DISABLED ---\r\n\r\n![image](https://user-images.githubusercontent.com/33222461/108908864-bc489500-761b-11eb-9693-a7f086266cc4.png)\r\n\r\n![image](https://user-images.githubusercontent.com/33222461/108908700-86a3ac00-761b-11eb-97df-d22af6885530.png)\r\n\r\n--- WITH \"no value limits\" ENABLED ---\r\n\r\n![image](https://user-images.githubusercontent.com/33222461/108909031-ebf79d00-761b-11eb-915f-250f74699bcf.png)\r\n\r\n![image](https://user-images.githubusercontent.com/33222461/108908978-dbdfbd80-761b-11eb-8fec-70dc6ef2e5d7.png)\r\n\r\n\r\n**System information**\r\nOperating system: Windows 10 (WSL2)\r\nSaleor/Saleor-storefront/Saleor-Dashboard version: 2.11\r\n\r\nApologies if I'm misunderstanding something or if this has already been raised - couldn't find it as an issue in any of the repos.\n", "before_files": [{"content": "from typing import TYPE_CHECKING, Union\n\nfrom django.conf import settings\nfrom django.db import models\nfrom django.db.models import Q\nfrom django_countries.fields import CountryField\nfrom django_measurement.models import MeasurementField\nfrom django_prices.models import MoneyField\nfrom measurement.measures import Weight\nfrom prices import Money, MoneyRange\n\nfrom ..core.permissions import ShippingPermissions\nfrom ..core.utils.translations import TranslationProxy\nfrom ..core.weight import (\n    WeightUnits,\n    convert_weight,\n    get_default_weight_unit,\n    zero_weight,\n)\nfrom . import ShippingMethodType\n\nif TYPE_CHECKING:\n    # flake8: noqa\n    from ..checkout.models import Checkout\n    from ..order.models import Order\n\n\ndef _applicable_weight_based_methods(weight, qs):\n    \"\"\"Return weight based shipping methods that are applicable for the total weight.\"\"\"\n    qs = qs.weight_based()\n    min_weight_matched = Q(minimum_order_weight__lte=weight)\n    no_weight_limit = Q(maximum_order_weight__isnull=True)\n    max_weight_matched = Q(maximum_order_weight__gte=weight)\n    return qs.filter(min_weight_matched & (no_weight_limit | max_weight_matched))\n\n\ndef _applicable_price_based_methods(price: Money, qs):\n    \"\"\"Return price based shipping methods that are applicable for the given total.\"\"\"\n    qs = qs.price_based()\n    min_price_matched = Q(minimum_order_price_amount__lte=price.amount)\n    no_price_limit = Q(maximum_order_price_amount__isnull=True)\n    max_price_matched = Q(maximum_order_price_amount__gte=price.amount)\n    return qs.filter(min_price_matched & (no_price_limit | max_price_matched))\n\n\ndef _get_weight_type_display(min_weight, max_weight):\n    default_unit = get_default_weight_unit()\n\n    if min_weight.unit != default_unit:\n        min_weight = convert_weight(min_weight, default_unit)\n    if max_weight and max_weight.unit != default_unit:\n        max_weight = convert_weight(max_weight, default_unit)\n\n    if max_weight is None:\n        return (\"%(min_weight)s and up\" % {\"min_weight\": min_weight},)\n    return \"%(min_weight)s to %(max_weight)s\" % {\n        \"min_weight\": min_weight,\n        \"max_weight\": max_weight,\n    }\n\n\nclass ShippingZone(models.Model):\n    name = models.CharField(max_length=100)\n    countries = CountryField(multiple=True, default=[], blank=True)\n    default = models.BooleanField(default=False)\n\n    def __str__(self):\n        return self.name\n\n    @property\n    def price_range(self):\n        prices = [\n            shipping_method.get_total()\n            for shipping_method in self.shipping_methods.all()\n        ]\n        if prices:\n            return MoneyRange(min(prices), max(prices))\n        return None\n\n    class Meta:\n        permissions = (\n            (ShippingPermissions.MANAGE_SHIPPING.codename, \"Manage shipping.\"),\n        )\n\n\nclass ShippingMethodQueryset(models.QuerySet):\n    def price_based(self):\n        return self.filter(type=ShippingMethodType.PRICE_BASED)\n\n    def weight_based(self):\n        return self.filter(type=ShippingMethodType.WEIGHT_BASED)\n\n    def applicable_shipping_methods(self, price: Money, weight, country_code):\n        \"\"\"Return the ShippingMethods that can be used on an order with shipment.\n\n        It is based on the given country code, and by shipping methods that are\n        applicable to the given price & weight total.\n        \"\"\"\n        qs = self.filter(\n            shipping_zone__countries__contains=country_code, currency=price.currency,\n        )\n        qs = qs.prefetch_related(\"shipping_zone\").order_by(\"price_amount\")\n        price_based_methods = _applicable_price_based_methods(price, qs)\n        weight_based_methods = _applicable_weight_based_methods(weight, qs)\n        return price_based_methods | weight_based_methods\n\n    def applicable_shipping_methods_for_instance(\n        self, instance: Union[\"Checkout\", \"Order\"], price: Money, country_code=None\n    ):\n        if not instance.is_shipping_required():\n            return None\n        if not instance.shipping_address:\n            return None\n\n        return self.applicable_shipping_methods(\n            price=price,\n            weight=instance.get_total_weight(),\n            country_code=country_code or instance.shipping_address.country.code,\n        )\n\n\nclass ShippingMethod(models.Model):\n    name = models.CharField(max_length=100)\n    type = models.CharField(max_length=30, choices=ShippingMethodType.CHOICES)\n    currency = models.CharField(\n        max_length=settings.DEFAULT_CURRENCY_CODE_LENGTH,\n        default=settings.DEFAULT_CURRENCY,\n    )\n    price_amount = models.DecimalField(\n        max_digits=settings.DEFAULT_MAX_DIGITS,\n        decimal_places=settings.DEFAULT_DECIMAL_PLACES,\n        default=0,\n    )\n    price = MoneyField(amount_field=\"price_amount\", currency_field=\"currency\")\n    shipping_zone = models.ForeignKey(\n        ShippingZone, related_name=\"shipping_methods\", on_delete=models.CASCADE\n    )\n\n    minimum_order_price_amount = models.DecimalField(\n        max_digits=settings.DEFAULT_MAX_DIGITS,\n        decimal_places=settings.DEFAULT_DECIMAL_PLACES,\n        default=0,\n        blank=True,\n        null=True,\n    )\n    minimum_order_price = MoneyField(\n        amount_field=\"minimum_order_price_amount\", currency_field=\"currency\"\n    )\n\n    maximum_order_price_amount = models.DecimalField(\n        max_digits=settings.DEFAULT_MAX_DIGITS,\n        decimal_places=settings.DEFAULT_DECIMAL_PLACES,\n        blank=True,\n        null=True,\n    )\n    maximum_order_price = MoneyField(\n        amount_field=\"maximum_order_price_amount\", currency_field=\"currency\"\n    )\n\n    minimum_order_weight = MeasurementField(\n        measurement=Weight,\n        unit_choices=WeightUnits.CHOICES,\n        default=zero_weight,\n        blank=True,\n        null=True,\n    )\n    maximum_order_weight = MeasurementField(\n        measurement=Weight, unit_choices=WeightUnits.CHOICES, blank=True, null=True\n    )\n\n    objects = ShippingMethodQueryset.as_manager()\n    translated = TranslationProxy()\n\n    class Meta:\n        ordering = (\"pk\",)\n\n    def __str__(self):\n        return self.name\n\n    def __repr__(self):\n        if self.type == ShippingMethodType.PRICE_BASED:\n            minimum = \"%s%s\" % (\n                self.minimum_order_price.amount,\n                self.minimum_order_price.currency,\n            )\n            max_price = self.maximum_order_price\n            maximum = (\n                \"%s%s\" % (max_price.amount, max_price.currency)\n                if max_price\n                else \"no limit\"\n            )\n            return \"ShippingMethod(type=%s min=%s, max=%s)\" % (\n                self.type,\n                minimum,\n                maximum,\n            )\n        return \"ShippingMethod(type=%s weight_range=(%s)\" % (\n            self.type,\n            _get_weight_type_display(\n                self.minimum_order_weight, self.maximum_order_weight\n            ),\n        )\n\n    def get_total(self):\n        return self.price\n\n\nclass ShippingMethodTranslation(models.Model):\n    language_code = models.CharField(max_length=10)\n    name = models.CharField(max_length=255, null=True, blank=True)\n    shipping_method = models.ForeignKey(\n        ShippingMethod, related_name=\"translations\", on_delete=models.CASCADE\n    )\n\n    class Meta:\n        unique_together = ((\"language_code\", \"shipping_method\"),)\n", "path": "saleor/shipping/models.py"}], "after_files": [{"content": "from typing import TYPE_CHECKING, Union\n\nfrom django.conf import settings\nfrom django.db import models\nfrom django.db.models import Q\nfrom django_countries.fields import CountryField\nfrom django_measurement.models import MeasurementField\nfrom django_prices.models import MoneyField\nfrom measurement.measures import Weight\nfrom prices import Money, MoneyRange\n\nfrom ..core.permissions import ShippingPermissions\nfrom ..core.utils.translations import TranslationProxy\nfrom ..core.weight import (\n    WeightUnits,\n    convert_weight,\n    get_default_weight_unit,\n    zero_weight,\n)\nfrom . import ShippingMethodType\n\nif TYPE_CHECKING:\n    # flake8: noqa\n    from ..checkout.models import Checkout\n    from ..order.models import Order\n\n\ndef _applicable_weight_based_methods(weight, qs):\n    \"\"\"Return weight based shipping methods that are applicable for the total weight.\"\"\"\n    qs = qs.weight_based()\n    min_weight_matched = Q(minimum_order_weight__lte=weight) | Q(\n        minimum_order_weight__isnull=True\n    )\n    max_weight_matched = Q(maximum_order_weight__gte=weight) | Q(\n        maximum_order_weight__isnull=True\n    )\n    return qs.filter(min_weight_matched & max_weight_matched)\n\n\ndef _applicable_price_based_methods(price: Money, qs):\n    \"\"\"Return price based shipping methods that are applicable for the given total.\"\"\"\n    qs = qs.price_based()\n    min_price_matched = Q(minimum_order_price_amount__lte=price.amount)\n    no_price_limit = Q(maximum_order_price_amount__isnull=True)\n    max_price_matched = Q(maximum_order_price_amount__gte=price.amount)\n    return qs.filter(min_price_matched & (no_price_limit | max_price_matched))\n\n\ndef _get_weight_type_display(min_weight, max_weight):\n    default_unit = get_default_weight_unit()\n\n    if min_weight.unit != default_unit:\n        min_weight = convert_weight(min_weight, default_unit)\n    if max_weight and max_weight.unit != default_unit:\n        max_weight = convert_weight(max_weight, default_unit)\n\n    if max_weight is None:\n        return (\"%(min_weight)s and up\" % {\"min_weight\": min_weight},)\n    return \"%(min_weight)s to %(max_weight)s\" % {\n        \"min_weight\": min_weight,\n        \"max_weight\": max_weight,\n    }\n\n\nclass ShippingZone(models.Model):\n    name = models.CharField(max_length=100)\n    countries = CountryField(multiple=True, default=[], blank=True)\n    default = models.BooleanField(default=False)\n\n    def __str__(self):\n        return self.name\n\n    @property\n    def price_range(self):\n        prices = [\n            shipping_method.get_total()\n            for shipping_method in self.shipping_methods.all()\n        ]\n        if prices:\n            return MoneyRange(min(prices), max(prices))\n        return None\n\n    class Meta:\n        permissions = (\n            (ShippingPermissions.MANAGE_SHIPPING.codename, \"Manage shipping.\"),\n        )\n\n\nclass ShippingMethodQueryset(models.QuerySet):\n    def price_based(self):\n        return self.filter(type=ShippingMethodType.PRICE_BASED)\n\n    def weight_based(self):\n        return self.filter(type=ShippingMethodType.WEIGHT_BASED)\n\n    def applicable_shipping_methods(self, price: Money, weight, country_code):\n        \"\"\"Return the ShippingMethods that can be used on an order with shipment.\n\n        It is based on the given country code, and by shipping methods that are\n        applicable to the given price & weight total.\n        \"\"\"\n        qs = self.filter(\n            shipping_zone__countries__contains=country_code, currency=price.currency,\n        )\n        qs = qs.prefetch_related(\"shipping_zone\").order_by(\"price_amount\")\n        price_based_methods = _applicable_price_based_methods(price, qs)\n        weight_based_methods = _applicable_weight_based_methods(weight, qs)\n        return price_based_methods | weight_based_methods\n\n    def applicable_shipping_methods_for_instance(\n        self, instance: Union[\"Checkout\", \"Order\"], price: Money, country_code=None\n    ):\n        if not instance.is_shipping_required():\n            return None\n        if not instance.shipping_address:\n            return None\n\n        return self.applicable_shipping_methods(\n            price=price,\n            weight=instance.get_total_weight(),\n            country_code=country_code or instance.shipping_address.country.code,\n        )\n\n\nclass ShippingMethod(models.Model):\n    name = models.CharField(max_length=100)\n    type = models.CharField(max_length=30, choices=ShippingMethodType.CHOICES)\n    currency = models.CharField(\n        max_length=settings.DEFAULT_CURRENCY_CODE_LENGTH,\n        default=settings.DEFAULT_CURRENCY,\n    )\n    price_amount = models.DecimalField(\n        max_digits=settings.DEFAULT_MAX_DIGITS,\n        decimal_places=settings.DEFAULT_DECIMAL_PLACES,\n        default=0,\n    )\n    price = MoneyField(amount_field=\"price_amount\", currency_field=\"currency\")\n    shipping_zone = models.ForeignKey(\n        ShippingZone, related_name=\"shipping_methods\", on_delete=models.CASCADE\n    )\n\n    minimum_order_price_amount = models.DecimalField(\n        max_digits=settings.DEFAULT_MAX_DIGITS,\n        decimal_places=settings.DEFAULT_DECIMAL_PLACES,\n        default=0,\n        blank=True,\n        null=True,\n    )\n    minimum_order_price = MoneyField(\n        amount_field=\"minimum_order_price_amount\", currency_field=\"currency\"\n    )\n\n    maximum_order_price_amount = models.DecimalField(\n        max_digits=settings.DEFAULT_MAX_DIGITS,\n        decimal_places=settings.DEFAULT_DECIMAL_PLACES,\n        blank=True,\n        null=True,\n    )\n    maximum_order_price = MoneyField(\n        amount_field=\"maximum_order_price_amount\", currency_field=\"currency\"\n    )\n\n    minimum_order_weight = MeasurementField(\n        measurement=Weight,\n        unit_choices=WeightUnits.CHOICES,\n        default=zero_weight,\n        blank=True,\n        null=True,\n    )\n    maximum_order_weight = MeasurementField(\n        measurement=Weight, unit_choices=WeightUnits.CHOICES, blank=True, null=True\n    )\n\n    objects = ShippingMethodQueryset.as_manager()\n    translated = TranslationProxy()\n\n    class Meta:\n        ordering = (\"pk\",)\n\n    def __str__(self):\n        return self.name\n\n    def __repr__(self):\n        if self.type == ShippingMethodType.PRICE_BASED:\n            minimum = \"%s%s\" % (\n                self.minimum_order_price.amount,\n                self.minimum_order_price.currency,\n            )\n            max_price = self.maximum_order_price\n            maximum = (\n                \"%s%s\" % (max_price.amount, max_price.currency)\n                if max_price\n                else \"no limit\"\n            )\n            return \"ShippingMethod(type=%s min=%s, max=%s)\" % (\n                self.type,\n                minimum,\n                maximum,\n            )\n        return \"ShippingMethod(type=%s weight_range=(%s)\" % (\n            self.type,\n            _get_weight_type_display(\n                self.minimum_order_weight, self.maximum_order_weight\n            ),\n        )\n\n    def get_total(self):\n        return self.price\n\n\nclass ShippingMethodTranslation(models.Model):\n    language_code = models.CharField(max_length=10)\n    name = models.CharField(max_length=255, null=True, blank=True)\n    shipping_method = models.ForeignKey(\n        ShippingMethod, related_name=\"translations\", on_delete=models.CASCADE\n    )\n\n    class Meta:\n        unique_together = ((\"language_code\", \"shipping_method\"),)\n", "path": "saleor/shipping/models.py"}]}