Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Updated django-prices to 2.1
NyanKiyoshi07cbdb1d7996
diff --git a/Pipfile b/Pipfileindex fd668de91e..c8bc53e83e 100644--- a/Pipfile+++ b/Pipfile@@ -23,7 +23,7 @@ django-impersonate = ">=1.3"django-measurement = "==3.0.0"django-mptt = ">=0.7.1"django-phonenumber-field = ">=1.3.0,<3.0"-django-prices = ">=1.0.2,<2.0.0"+django-prices = ">=2.1.0,<3.0.0"django-prices-openexchangerates = ">=1.0.0"django-prices-vatlayer = ">=1.0.2"django-redis = ">=4.0.0"diff --git a/Pipfile.lock b/Pipfile.lockindex dda1d990cb..57893564c0 100644--- a/Pipfile.lock+++ b/Pipfile.lock@@ -1,7 +1,7 @@{"_meta": {"hash": {- "sha256": "38160e9ab3699e3044ca21910925c51b70700f903244f092686e88b8028ebdda"+ "sha256": "588f5d4fc7c63888998c268b17c2e6d0702edbcc00e0f17777f3b99a1f30fd68"},"pipfile-spec": 6,"requires": {@@ -69,18 +69,18 @@},"boto3": {"hashes": [- "sha256:1a228661611cb99c3c54f5bdbdc29d9d7ef5341676a644d2508eeeff7b8b2fe3",- "sha256:c25d1089676213bda140c5b6faacd008b93203d27f1707cf0efc827d46cd719d"+ "sha256:3a8a8af144df27643f5e444ae437b5bc45e94b37de15dabb5bb799a0205f1d8f",+ "sha256:dacfd1651860eda526abaeb5f9eee2063043a75d4c555cc7b0c22a7989bf88cd"],"index": "pypi",- "version": "==1.9.212"+ "version": "==1.9.213"},"botocore": {"hashes": [- "sha256:123b1d703ee3445850f00969e07e276f949834c43048b6a9a0e5e7966a523108",- "sha256:bebd21f9c8badcb895fb735743d2a8df8289162314b9346879cb74a1d698e075"+ "sha256:14ab8371f883c47348e749c4d8773366dd2cc549038e9eaabe21fb1d05bca7b5",+ "sha256:b76a264c0781e4f19138617e4201e8e67fa6dd331db32f4b6273fc18a433f4ec"],- "version": "==1.12.212"+ "version": "==1.12.213"},"braintree": {"hashes": [@@ -316,10 +316,10 @@},"django-prices": {"hashes": [- "sha256:0d997da5f34a3f16aff9ecf586c78b67b747cd292459b85a898cfc0b44f907fb"+ "sha256:bf237495ca0d1e8ce6183909815e11d3f8e8c6a27ef9ddbb3b1e9829874d6e55"],"index": "pypi",- "version": "==1.0.4"+ "version": "==2.1.0"},"django-prices-openexchangerates": {"hashes": [@@ -1318,14 +1318,6 @@],"version": "==0.19"},- "importlib-resources": {- "hashes": [- "sha256:6e2783b2538bd5a14678284a3962b0660c715e5a0f10243fd5e00a4b5974f50b",- "sha256:d3279fd0f6f847cced9f7acc19bd3e5df54d34f93a2e7bb5f238f81545787078"- ],- "markers": "python_version < '3.7'",- "version": "==1.0.2"- },"isort": {"hashes": ["sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1",@@ -1343,26 +1335,26 @@},"lazy-object-proxy": {"hashes": [- "sha256:159a745e61422217881c4de71f9eafd9d703b93af95618635849fe469a283661",- "sha256:23f63c0821cc96a23332e45dfaa83266feff8adc72b9bcaef86c202af765244f",- "sha256:3b11be575475db2e8a6e11215f5aa95b9ec14de658628776e10d96fa0b4dac13",- "sha256:3f447aff8bc61ca8b42b73304f6a44fa0d915487de144652816f950a3f1ab821",- "sha256:4ba73f6089cd9b9478bc0a4fa807b47dbdb8fad1d8f31a0f0a5dbf26a4527a71",- "sha256:4f53eadd9932055eac465bd3ca1bd610e4d7141e1278012bd1f28646aebc1d0e",- "sha256:64483bd7154580158ea90de5b8e5e6fc29a16a9b4db24f10193f0c1ae3f9d1ea",- "sha256:6f72d42b0d04bfee2397aa1862262654b56922c20a9bb66bb76b6f0e5e4f9229",- "sha256:7c7f1ec07b227bdc561299fa2328e85000f90179a2f44ea30579d38e037cb3d4",- "sha256:7c8b1ba1e15c10b13cad4171cfa77f5bb5ec2580abc5a353907780805ebe158e",- "sha256:8559b94b823f85342e10d3d9ca4ba5478168e1ac5658a8a2f18c991ba9c52c20",- "sha256:a262c7dfb046f00e12a2bdd1bafaed2408114a89ac414b0af8755c696eb3fc16",- "sha256:acce4e3267610c4fdb6632b3886fe3f2f7dd641158a843cf6b6a68e4ce81477b",- "sha256:be089bb6b83fac7f29d357b2dc4cf2b8eb8d98fe9d9ff89f9ea6012970a853c7",- "sha256:bfab710d859c779f273cc48fb86af38d6e9210f38287df0069a63e40b45a2f5c",- "sha256:c10d29019927301d524a22ced72706380de7cfc50f767217485a912b4c8bd82a",- "sha256:dd6e2b598849b3d7aee2295ac765a578879830fb8966f70be8cd472e6069932e",- "sha256:e408f1eacc0a68fed0c08da45f31d0ebb38079f043328dce69ff133b95c29dc1"- ],- "version": "==1.4.1"+ "sha256:02b260c8deb80db09325b99edf62ae344ce9bc64d68b7a634410b8e9a568edbf",+ "sha256:18f9c401083a4ba6e162355873f906315332ea7035803d0fd8166051e3d402e3",+ "sha256:1f2c6209a8917c525c1e2b55a716135ca4658a3042b5122d4e3413a4030c26ce",+ "sha256:2f06d97f0ca0f414f6b707c974aaf8829c2292c1c497642f63824119d770226f",+ "sha256:616c94f8176808f4018b39f9638080ed86f96b55370b5a9463b2ee5c926f6c5f",+ "sha256:63b91e30ef47ef68a30f0c3c278fbfe9822319c15f34b7538a829515b84ca2a0",+ "sha256:77b454f03860b844f758c5d5c6e5f18d27de899a3db367f4af06bec2e6013a8e",+ "sha256:83fe27ba321e4cfac466178606147d3c0aa18e8087507caec78ed5a966a64905",+ "sha256:84742532d39f72df959d237912344d8a1764c2d03fe58beba96a87bfa11a76d8",+ "sha256:874ebf3caaf55a020aeb08acead813baf5a305927a71ce88c9377970fe7ad3c2",+ "sha256:9f5caf2c7436d44f3cec97c2fa7791f8a675170badbfa86e1992ca1b84c37009",+ "sha256:a0c8758d01fcdfe7ae8e4b4017b13552efa7f1197dd7358dc9da0576f9d0328a",+ "sha256:a4def978d9d28cda2d960c279318d46b327632686d82b4917516c36d4c274512",+ "sha256:ad4f4be843dace866af5fc142509e9b9817ca0c59342fdb176ab6ad552c927f5",+ "sha256:ae33dd198f772f714420c5ab698ff05ff900150486c648d29951e9c70694338e",+ "sha256:b4a2b782b8a8c5522ad35c93e04d60e2ba7f7dcb9271ec8e8c3e08239be6c7b4",+ "sha256:c462eb33f6abca3b34cdedbe84d761f31a60b814e173b98ede3c81bb48967c4f",+ "sha256:fd135b8d35dfdcdb984828c84d695937e58cc5f49e1c854eb311c4d6aa03f4f1"+ ],+ "version": "==1.4.2"},"markupsafe": {"hashes": [diff --git a/package-lock.json b/package-lock.jsonindex f752f70087..d9d62d6d02 100644--- a/package-lock.json+++ b/package-lock.json@@ -5378,7 +5378,8 @@"ansi-regex": {"version": "2.1.1","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"aproba": {"version": "1.2.0",@@ -5399,12 +5400,14 @@"balanced-match": {"version": "1.0.0","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"brace-expansion": {"version": "1.1.11","bundled": true,"dev": true,+ "optional": true,"requires": {"balanced-match": "^1.0.0","concat-map": "0.0.1"@@ -5419,17 +5422,20 @@"code-point-at": {"version": "1.1.0","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"concat-map": {"version": "0.0.1","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"console-control-strings": {"version": "1.1.0","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"core-util-is": {"version": "1.0.2",@@ -5546,7 +5552,8 @@"inherits": {"version": "2.0.3","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"ini": {"version": "1.3.5",@@ -5558,6 +5565,7 @@"version": "1.0.0","bundled": true,"dev": true,+ "optional": true,"requires": {"number-is-nan": "^1.0.0"}@@ -5572,6 +5580,7 @@"version": "3.0.4","bundled": true,"dev": true,+ "optional": true,"requires": {"brace-expansion": "^1.1.7"}@@ -5579,12 +5588,14 @@"minimist": {"version": "0.0.8","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"minipass": {"version": "2.3.5","bundled": true,"dev": true,+ "optional": true,"requires": {"safe-buffer": "^5.1.2","yallist": "^3.0.0"@@ -5603,6 +5614,7 @@"version": "0.5.1","bundled": true,"dev": true,+ "optional": true,"requires": {"minimist": "0.0.8"}@@ -5690,7 +5702,8 @@"number-is-nan": {"version": "1.0.1","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"object-assign": {"version": "4.1.1",@@ -5702,6 +5715,7 @@"version": "1.4.0","bundled": true,"dev": true,+ "optional": true,"requires": {"wrappy": "1"}@@ -5787,7 +5801,8 @@"safe-buffer": {"version": "5.1.2","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"safer-buffer": {"version": "2.1.2",@@ -5823,6 +5838,7 @@"version": "1.0.2","bundled": true,"dev": true,+ "optional": true,"requires": {"code-point-at": "^1.0.0","is-fullwidth-code-point": "^1.0.0",@@ -5842,6 +5858,7 @@"version": "3.0.1","bundled": true,"dev": true,+ "optional": true,"requires": {"ansi-regex": "^2.0.0"}@@ -5885,12 +5902,14 @@"wrappy": {"version": "1.0.2","bundled": true,- "dev": true+ "dev": true,+ "optional": true},"yallist": {"version": "3.0.3","bundled": true,- "dev": true+ "dev": true,+ "optional": true}}},diff --git a/requirements.txt b/requirements.txtindex 58acfc2983..dc6f95c368 100644--- a/requirements.txt+++ b/requirements.txt@@ -6,12 +6,12 @@ babel==2.7.0beautifulsoup4==4.7.1billiard==3.6.1.0bleach==2.1.4-boto3==1.9.210-botocore==1.12.210+boto3==1.9.213+botocore==1.12.213braintree==3.49.0cachetools==3.1.1cairocffi==1.0.2-cairosvg==2.4.0+cairosvg==2.4.1celery[redis]==4.3.0certifi==2019.6.16cffi==1.12.3@@ -36,7 +36,7 @@ django-mptt==0.10.0django-phonenumber-field==2.4.0django-prices-openexchangerates==1.0.1django-prices-vatlayer==1.0.2-django-prices==1.0.4+django-prices==2.1.0django-recaptcha==1.5.0django-redis==4.10.0django-render-block==0.6@@ -50,7 +50,7 @@ docutils==0.15.2draftjs-sanitizer==1.0.0elasticsearch-dsl==6.0.1elasticsearch==6.3.1-faker==2.0.0+faker==2.0.1freezegun==0.3.12google-api-core==1.14.2google-auth==1.6.3@@ -101,24 +101,24 @@ python-dateutil==2.8.0 ; python_version >= '2.7'python3-openid==3.1.0 ; python_version >= '3.0'pytz==2019.2razorpay==1.2.0-redis==3.3.7+redis==3.3.8requests-oauthlib==1.2.0requests==2.22.0rsa==4.0rx==1.6.1s3transfer==0.2.1-sentry-sdk==0.11.0+sentry-sdk==0.11.1singledispatch==3.4.0.3six==1.12.0social-auth-app-django==3.1.0social-auth-core==3.2.0soupsieve==1.9.3sqlparse==0.3.0-stripe==2.35.0+stripe==2.35.1sympy==1.4text-unidecode==1.2tinycss2==1.0.2-tqdm==4.33.0+tqdm==4.34.0typing==3.7.4urllib3==1.25.3uwsgi==2.0.18 ; platform_system != 'Windows'diff --git a/requirements_dev.txt b/requirements_dev.txtindex 294658b3d0..ccd7db3ff2 100644--- a/requirements_dev.txt+++ b/requirements_dev.txt@@ -27,7 +27,7 @@ idna==2.8importlib-metadata==0.19isort==4.3.21jinja2==2.10.1-lazy-object-proxy==1.4.1+lazy-object-proxy==1.4.2markupsafe==1.1.1mccabe==0.6.1more-itertools==7.2.0@@ -52,7 +52,7 @@ pytest-forked==1.0.2pytest-mock==1.10.4pytest-vcr==1.0.2pytest-xdist==1.29.0-pytest==5.1.0+pytest==5.1.1python-slugify==1.2.6pytz==2019.2pyyaml==5.1.2diff --git a/saleor/checkout/forms.py b/saleor/checkout/forms.pyindex bccd856825..8a8e8977dd 100644--- a/saleor/checkout/forms.py+++ b/saleor/checkout/forms.py@@ -393,10 +393,8 @@ class CheckoutVoucherForm(forms.ModelForm):if "voucher" in cleaned_data:voucher = cleaned_data["voucher"]try:- discount_amount = get_voucher_discount_for_checkout(- voucher, self.instance- )- cleaned_data["discount_amount"] = discount_amount+ discount = get_voucher_discount_for_checkout(voucher, self.instance)+ cleaned_data["discount"] = discountexcept NotApplicable as e:self.add_error("voucher", smart_text(e))return cleaned_data@@ -408,5 +406,5 @@ class CheckoutVoucherForm(forms.ModelForm):self.instance.translated_discount_name = (voucher.translated.name if voucher.translated.name != voucher.name else "")- self.instance.discount_amount = self.cleaned_data["discount_amount"]+ self.instance.discount = self.cleaned_data["discount"]return super().save(commit)diff --git a/saleor/checkout/migrations/0001_initial.py b/saleor/checkout/migrations/0001_initial.pyindex 840cfc2b51..d25ece23d3 100644--- a/saleor/checkout/migrations/0001_initial.py+++ b/saleor/checkout/migrations/0001_initial.py@@ -4,7 +4,6 @@ from __future__ import unicode_literalsimport uuidimport django.core.validators-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -63,12 +62,7 @@ class Migration(migrations.Migration):("checkout_data", models.TextField(null=True, editable=False)),("total",- django_prices.models.MoneyField(- default=0,- currency=settings.DEFAULT_CURRENCY,- max_digits=12,- decimal_places=2,- ),+ models.DecimalField(default=0, max_digits=12, decimal_places=2),),("quantity", models.PositiveIntegerField(default=0)),(diff --git a/saleor/checkout/migrations/0002_auto_20170206_0407.py b/saleor/checkout/migrations/0002_auto_20170206_0407.pyindex 7dcdda32a5..1cdd139008 100644--- a/saleor/checkout/migrations/0002_auto_20170206_0407.py+++ b/saleor/checkout/migrations/0002_auto_20170206_0407.py@@ -3,8 +3,6 @@from __future__ import unicode_literalsimport django.db.models.deletion-import django_prices.models-from django.conf import settingsfrom django.contrib.postgres import fieldsfrom django.db import migrations, models@@ -50,12 +48,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="cart",name="total",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- verbose_name="total",+ field=models.DecimalField(+ decimal_places=2, default=0, max_digits=12, verbose_name="total"),),migrations.AlterField(diff --git a/saleor/checkout/migrations/0005_auto_20180108_0814.py b/saleor/checkout/migrations/0005_auto_20180108_0814.pyindex cf50530338..91b9cc7858 100644--- a/saleor/checkout/migrations/0005_auto_20180108_0814.py+++ b/saleor/checkout/migrations/0005_auto_20180108_0814.py@@ -6,7 +6,6 @@ import uuidimport django.core.validatorsimport django.db.models.deletion-import django_prices.modelsfrom django.conf import settingsfrom django.contrib.postgres import fieldsfrom django.db import migrations, models@@ -70,12 +69,7 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="cart",name="total",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.AlterField(model_name="cart",diff --git a/saleor/checkout/migrations/0007_merge_cart_with_checkout.py b/saleor/checkout/migrations/0007_merge_cart_with_checkout.pyindex e330bf8d5a..ab43e49f38 100644--- a/saleor/checkout/migrations/0007_merge_cart_with_checkout.py+++ b/saleor/checkout/migrations/0007_merge_cart_with_checkout.py@@ -1,8 +1,6 @@# Generated by Django 2.0.3 on 2018-05-29 08:18import django.db.models.deletion-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -48,12 +46,7 @@ class Migration(migrations.Migration):migrations.AddField(model_name="cart",name="discount_amount",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.AddField(model_name="cart",diff --git a/saleor/checkout/migrations/0015_auto_20181017_1346.py b/saleor/checkout/migrations/0015_auto_20181017_1346.pyindex bbec093e15..978e0a8d81 100644--- a/saleor/checkout/migrations/0015_auto_20181017_1346.py+++ b/saleor/checkout/migrations/0015_auto_20181017_1346.py@@ -1,10 +1,6 @@# Generated by Django 2.1.2 on 2018-10-17 18:46-import django_prices.models-from django.conf import settings-from django.db import migrations--import saleor.core+from django.db import migrations, modelsclass Migration(migrations.Migration):@@ -15,11 +11,6 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="cart",name="discount_amount",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=saleor.core.taxes.zero_money,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),)]diff --git a/saleor/checkout/migrations/0021_django_price_2.py b/saleor/checkout/migrations/0021_django_price_2.pynew file mode 100644index 0000000000..da82f26bb8--- /dev/null+++ b/saleor/checkout/migrations/0021_django_price_2.py@@ -0,0 +1,16 @@+# Generated by Django 2.2.4 on 2019-08-14 09:13+from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [("checkout", "0020_auto_20190723_0722")]++ operations = [+ migrations.AddField(+ model_name="checkout",+ name="currency",+ field=models.CharField(default=settings.DEFAULT_CURRENCY, max_length=3),+ )+ ]diff --git a/saleor/checkout/models.py b/saleor/checkout/models.pyindex df689915db..81efa3445b 100644--- a/saleor/checkout/models.py+++ b/saleor/checkout/models.py@@ -9,6 +9,7 @@ from django.core.validators import MinValueValidatorfrom django.db import modelsfrom django.utils.encoding import smart_strfrom django_prices.models import MoneyField+from prices import Moneyfrom ..account.models import Addressfrom ..core.models import ModelWithMetadata@@ -66,13 +67,17 @@ class Checkout(ModelWithMetadata):on_delete=models.SET_NULL,)note = models.TextField(blank=True, default="")- discount_amount = MoneyField(- currency=settings.DEFAULT_CURRENCY,++ currency = models.CharField(max_length=3, default=settings.DEFAULT_CURRENCY)++ discount_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- default=zero_money,+ default=0,)+ discount = MoneyField(amount_field="discount_amount", currency_field="currency")discount_name = models.CharField(max_length=255, blank=True, null=True)+translated_discount_name = models.CharField(max_length=255, blank=True, null=True)voucher_code = models.CharField(max_length=12, blank=True, null=True)gift_cards = models.ManyToManyField(GiftCard, blank=True, related_name="checkouts")@@ -112,19 +117,17 @@ class Checkout(ModelWithMetadata):def get_total(self, discounts=None):"""Return the total cost of the checkout."""- total = (- self.get_subtotal(discounts)- + self.get_shipping_price()- - self.discount_amount- )+ total = self.get_subtotal(discounts) + self.get_shipping_price() - self.discountreturn max(total, zero_money(total.currency))def get_total_gift_cards_balance(self):"""Return the total balance of the gift cards assigned to the checkout."""- balance = self.gift_cards.aggregate(models.Sum("current_balance"))[- "current_balance__sum"+ balance = self.gift_cards.aggregate(models.Sum("current_balance_amount"))[+ "current_balance_amount__sum"]- return balance or zero_money(currency=settings.DEFAULT_CURRENCY)+ if balance is None:+ return zero_money(currency=self.currency)+ return Money(balance, self.currency)def get_total_weight(self):# Cannot use `sum` as it parses an empty Weight to an intdiff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 1b5b093a02..7876018829 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -7,11 +7,11 @@ from uuid import UUIDfrom django.contrib import messagesfrom django.core.exceptions import ValidationErrorfrom django.db import transaction-from django.db.models import Sum+from django.db.models import Max, Min, Sumfrom django.utils import timezonefrom django.utils.encoding import smart_textfrom django.utils.translation import get_language, pgettext, pgettext_lazy-from prices import MoneyRange, TaxedMoneyRange+from prices import Money, MoneyRange, TaxedMoneyRangefrom ..account.forms import get_address_formfrom ..account.models import Address, User@@ -820,7 +820,7 @@ def _get_products_voucher_discount(checkout, voucher, discounts=None):return get_products_voucher_discount(voucher, prices)-def get_voucher_discount_for_checkout(voucher, checkout, discounts=None):+def get_voucher_discount_for_checkout(voucher, checkout, discounts=None) -> Money:"""Calculate discount value depending on voucher and discount types.Raise NotApplicable if voucher of given type cannot be applied.@@ -872,7 +872,7 @@ def recalculate_checkout_discount(checkout, discounts):else:manager = get_extensions_manager()subtotal = manager.calculate_checkout_subtotal(checkout, discounts).gross- checkout.discount_amount = min(discount, subtotal)+ checkout.discount = min(discount, subtotal)checkout.discount_name = str(voucher)checkout.translated_discount_name = (voucher.translated.name@@ -884,6 +884,7 @@ def recalculate_checkout_discount(checkout, discounts):"translated_discount_name","discount_amount","discount_name",+ "currency",])else:@@ -925,13 +926,13 @@ def add_voucher_to_checkout(checkout: Checkout, voucher: Voucher, discounts=NoneRaise NotApplicable if voucher of given type cannot be applied."""- discount_amount = get_voucher_discount_for_checkout(voucher, checkout, discounts)+ discount = get_voucher_discount_for_checkout(voucher, checkout, discounts)checkout.voucher_code = voucher.codecheckout.discount_name = voucher.namecheckout.translated_discount_name = (voucher.translated.name if voucher.translated.name != voucher.name else "")- checkout.discount_amount = discount_amount+ checkout.discount = discountcheckout.save(update_fields=["voucher_code",@@ -962,13 +963,14 @@ def remove_voucher_from_checkout(checkout: Checkout):checkout.voucher_code = Nonecheckout.discount_name = Nonecheckout.translated_discount_name = None- checkout.discount_amount = zero_money()+ checkout.discount = zero_money()checkout.save(update_fields=["voucher_code","discount_name","translated_discount_name","discount_amount",+ "currency",])@@ -1006,13 +1008,18 @@ def get_shipping_price_estimate(checkout: Checkout, discounts, country_code):if shipping_methods is None:return None- shipping_methods = shipping_methods.values_list("price", flat=True)+ min_price_amount, max_price_amount = shipping_methods.aggregate(+ price_amount_min=Min("price_amount"), price_amount_max=Max("price_amount")+ ).values()- if not shipping_methods:+ if min_price_amount is None:return Nonemanager = get_extensions_manager()- prices = MoneyRange(start=min(shipping_methods), stop=max(shipping_methods))+ prices = MoneyRange(+ start=Money(min_price_amount, checkout.currency),+ stop=Money(max_price_amount, checkout.currency),+ )return manager.apply_taxes_to_shipping_price_range(prices, country_code)@@ -1045,7 +1052,7 @@ def _get_voucher_data_for_order(checkout):add_voucher_usage_by_customer(voucher, checkout.get_customer_email())return {"voucher": voucher,- "discount_amount": checkout.discount_amount,+ "discount": checkout.discount,"discount_name": checkout.discount_name,"translated_discount_name": checkout.translated_discount_name,}@@ -1177,7 +1184,7 @@ def prepare_order_data(*, checkout: Checkout, tracking_code: str, discounts) ->order_data["total_price_left"] = (manager.calculate_checkout_subtotal(checkout, discounts)+ shipping_total- - checkout.discount_amount+ - checkout.discount).grossmanager.preprocess_order_creation(checkout, discounts)diff --git a/saleor/core/templatetags/materializecss.py b/saleor/core/templatetags/materializecss.pyindex 9222f82cb5..aa15cf1a6c 100644--- a/saleor/core/templatetags/materializecss.py+++ b/saleor/core/templatetags/materializecss.py@@ -74,7 +74,7 @@ def is_radio(field):@register.filterdef is_date_input(field):- return isinstance(field.field.widget, forms.DateInput)+ return isinstance(field.field.widget, (forms.DateInput, forms.DateTimeInput))@register.filterdiff --git a/saleor/core/utils/json_serializer.py b/saleor/core/utils/json_serializer.pyindex c726940d96..5de21b529e 100644--- a/saleor/core/utils/json_serializer.py+++ b/saleor/core/utils/json_serializer.py@@ -1,11 +1,4 @@-import json--from django.core.serializers.base import DeserializationError-from django.core.serializers.json import (- DjangoJSONEncoder,- PythonDeserializer,- Serializer as JsonSerializer,-)+from django.core.serializers.json import DjangoJSONEncoder, Serializer as JsonSerializerfrom draftjs_sanitizer import SafeJSONEncoderfrom prices import Money@@ -31,30 +24,3 @@ class HTMLSafeJSON(SafeJSONEncoder, DjangoJSONEncoder):It is used for integrating JSON into HTML content in addition toserializing Django objects."""---def object_hook(obj):- if "_type" in obj and obj["_type"] == MONEY_TYPE:- return Money(obj["amount"], obj["currency"])- return obj---def Deserializer(stream_or_string, **options):- """Deserialize a stream or string of JSON data.-- This is a slightly modified copy of Django implementation with additional- argument <object_hook> in json.loads.- """- if not isinstance(stream_or_string, (bytes, str)):- stream_or_string = stream_or_string.read()- if isinstance(stream_or_string, bytes):- stream_or_string = stream_or_string.decode()- try:- objects = json.loads(stream_or_string, object_hook=object_hook)- yield from PythonDeserializer(objects, **options)- except Exception as exc:- # ugly construction to overcome pylint's warning- # "The except handler raises immediately"- if isinstance(exc, (GeneratorExit, DeserializationError)):- raise- raise DeserializationError() from excdiff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex 8d207fd12e..72c5dfb223 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -14,12 +14,11 @@ from django.utils import timezonefrom faker import Factoryfrom faker.providers import BaseProviderfrom measurement.measures import Weight-from prices import Money+from prices import Money, TaxedMoneyfrom ...account.models import Address, Userfrom ...account.utils import store_user_addressfrom ...checkout import AddressType-from ...core.utils.json_serializer import object_hookfrom ...core.weight import zero_weightfrom ...discount import DiscountValueType, VoucherTypefrom ...discount.models import Sale, Voucher@@ -190,13 +189,12 @@ def create_products(products_data, placeholder_dir, create_images):# We are skipping products without imagesif pk not in IMAGES_MAPPING:continue+defaults = product["fields"]+ set_field_as_money(defaults, "price")defaults["weight"] = get_weight(defaults["weight"])defaults["category_id"] = defaults.pop("category")defaults["product_type_id"] = defaults.pop("product_type")- defaults["price"] = get_in_default_currency(- defaults, "price", settings.DEFAULT_CURRENCY- )defaults["attributes"] = json.loads(defaults["attributes"])product, _ = Product.objects.update_or_create(pk=pk, defaults=defaults)@@ -217,19 +215,15 @@ def create_product_variants(variants_data):continuedefaults["product_id"] = product_iddefaults["attributes"] = json.loads(defaults["attributes"])- defaults["price_override"] = get_in_default_currency(- defaults, "price_override", settings.DEFAULT_CURRENCY- )- defaults["cost_price"] = get_in_default_currency(- defaults, "cost_price", settings.DEFAULT_CURRENCY- )+ set_field_as_money(defaults, "price_override")+ set_field_as_money(defaults, "cost_price")ProductVariant.objects.update_or_create(pk=pk, defaults=defaults)-def get_in_default_currency(defaults, field, currency):- if field in defaults and defaults[field] is not None:- return Money(defaults[field].amount, currency)- return None+def set_field_as_money(defaults, field):+ amount_field = f"{field}_amount"+ if amount_field in defaults and defaults[amount_field] is not None:+ defaults[field] = Money(defaults[amount_field], settings.DEFAULT_CURRENCY)def create_products_by_schema(placeholder_dir, create_images):@@ -237,7 +231,7 @@ def create_products_by_schema(placeholder_dir, create_images):settings.PROJECT_ROOT, "saleor", "static", "populatedb_data.json")with open(path) as f:- db_items = json.load(f, object_hook=object_hook)+ db_items = json.load(f)types = defaultdict(list)# Sort db objects by its modelfor item in db_items:@@ -369,6 +363,7 @@ def create_order_lines(order, discounts, how_many=10):variant.quantity += quantityvariant.quantity_allocated += quantityunit_price = variant.get_price(discounts)+ unit_price = TaxedMoney(net=unit_price, gross=unit_price)lines.append(OrderLine(order=order,@@ -377,8 +372,7 @@ def create_order_lines(order, discounts, how_many=10):is_shipping_required=variant.is_shipping_required(),quantity=quantity,variant=variant,- unit_price_net=unit_price,- unit_price_gross=unit_price,+ unit_price=unit_price,tax_rate=0,))@@ -387,11 +381,11 @@ def create_order_lines(order, discounts, how_many=10):manager = get_extensions_manager()for line in lines:unit_price = manager.calculate_order_line_unit(line)- line.unit_price_net = unit_price.net- line.unit_price_gross = unit_price.gross+ line.unit_price = unit_priceline.tax_rate = unit_price.tax / unit_price.netOrderLine.objects.bulk_update(- lines, ["unit_price_net", "unit_price_gross", "tax_rate"]+ lines,+ ["unit_price_net_amount", "unit_price_gross_amount", "currency", "tax_rate"],)return lines@@ -495,8 +489,8 @@ def create_shipping_zone(shipping_methods_names, countries, shipping_zone_name):if random.randint(0, 1)else ShippingMethodType.WEIGHT_BASED),- minimum_order_price=0,- maximum_order_price=None,+ minimum_order_price=Money(0, settings.DEFAULT_CURRENCY),+ maximum_order_price_amount=None,minimum_order_weight=0,maximum_order_weight=None,)@@ -819,7 +813,7 @@ def create_vouchers():"name": "Big order discount","discount_value_type": DiscountValueType.FIXED,"discount_value": 25,- "min_amount_spent": 200,+ "min_spent": Money(200, settings.DEFAULT_CURRENCY),},)if created:@@ -834,7 +828,11 @@ def create_gift_card():)gift_card, created = GiftCard.objects.get_or_create(code="Gift_card_10",- defaults={"user": user, "initial_balance": 10, "current_balance": 10},+ defaults={+ "user": user,+ "initial_balance": Money(10, settings.DEFAULT_CURRENCY),+ "current_balance": Money(10, settings.DEFAULT_CURRENCY),+ },)if created:yield "Gift card #%d" % gift_card.iddiff --git a/saleor/dashboard/discount/filters.py b/saleor/dashboard/discount/filters.pyindex 2ffd7e951b..35d6568122 100644--- a/saleor/dashboard/discount/filters.py+++ b/saleor/dashboard/discount/filters.py@@ -29,8 +29,8 @@ SORT_BY_FIELDS_LABELS_VOUCHER = {"start_date": pgettext_lazy("Voucher list sorting option", "start_date"),"end_date": pgettext_lazy("Voucher list sorting option", "end_date"),"used": pgettext_lazy("Voucher list sorting option", "used"),- "min_amount_spent": pgettext_lazy(- "Voucher list sorting option", "min_amount_spent"+ "min_spent_amount": pgettext_lazy(+ "Voucher list sorting option", "min_spent_amount"),}@@ -115,9 +115,9 @@ class VoucherFilter(SortedFilterSet):widget=DateRangeWidget,method=filter_by_date_range,)- min_amount_spent = RangeFilter(+ min_spent_amount = RangeFilter(label=pgettext_lazy("Voucher list sorting filter", "Minimum amount spent"),- field_name="min_amount_spent",+ field_name="min_spent_amount",)sort_by = OrderingFilter(label=pgettext_lazy("Voucher list sorting filter label", "Sort by"),diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.pyindex 3d40ee886a..b6025a641d 100644--- a/saleor/dashboard/discount/forms.py+++ b/saleor/dashboard/discount/forms.py@@ -15,9 +15,11 @@ from ...product.tasks import update_products_minimal_variant_prices_of_discount_from ..forms import AjaxSelect2MultipleChoiceFieldMinAmountSpent = MoneyField(- min_value=zero_money(),+ available_currencies=settings.AVAILABLE_CURRENCIES,+ min_values=[zero_money()],+ max_digits=settings.DEFAULT_MAX_DIGITS,+ decimal_places=settings.DEFAULT_DECIMAL_PLACES,required=False,- currency=settings.DEFAULT_CURRENCY,label=pgettext_lazy("Lowest value for order to be able to use the voucher","Apply only if the purchase value is greater than or equal to",@@ -87,12 +89,13 @@ class VoucherForm(forms.ModelForm):class Meta:model = Voucherexclude = [- "min_amount_spent",+ "min_spent","countries","products","collections","categories","used",+ "currency",]labels = {"type": pgettext_lazy("Discount type", "Discount type"),@@ -121,8 +124,26 @@ class VoucherForm(forms.ModelForm):super().__init__(*args, **kwargs)-class ShippingVoucherForm(forms.ModelForm):- min_amount_spent = MinAmountSpent+class MinSpentVoucherBaseForm(forms.ModelForm):+ min_spent = MinAmountSpent++ def __init__(self, *args, **kwargs):+ instance = kwargs["instance"]+ initial = kwargs.setdefault("initial", {})+ if instance.min_spent:+ initial.setdefault("min_spent", instance.min_spent)+ super().__init__(*args, **kwargs)++ def save(self, commit=True):+ min_spent = self.cleaned_data["min_spent"]+ if min_spent is not None:+ if not min_spent.currency:+ min_spent.currency = settings.DEFAULT_CURRENCY+ self.instance.min_spent = min_spent+ return super().save(commit=commit)+++class ShippingVoucherForm(MinSpentVoucherBaseForm):countries = forms.MultipleChoiceField(choices=countries,required=False,@@ -134,15 +155,13 @@ class ShippingVoucherForm(forms.ModelForm):class Meta:model = Voucher- fields = ["countries", "min_amount_spent", "min_checkout_items_quantity"]-+ fields = ["countries", "min_checkout_items_quantity"]-class EntireOrderVoucherForm(forms.ModelForm):- min_amount_spent = MinAmountSpent+class EntireOrderVoucherForm(MinSpentVoucherBaseForm):class Meta:model = Voucher- fields = ["min_amount_spent", "min_checkout_items_quantity"]+ fields = ["min_spent", "min_checkout_items_quantity"]def save(self, commit=True):self.instance.category = None@@ -151,9 +170,8 @@ class EntireOrderVoucherForm(forms.ModelForm):return super().save(commit)-class CommonVoucherForm(forms.ModelForm):+class CommonVoucherForm(MinSpentVoucherBaseForm):use_required_attribute = False- min_amount_spent = MinAmountSpentapply_once_per_order = forms.BooleanField(required=False,label=pgettext_lazy(@@ -192,7 +210,6 @@ class SpecificProductVoucherForm(CommonVoucherForm):"collections","categories","apply_once_per_order",- "min_amount_spent","min_checkout_items_quantity",]labels = {@@ -219,12 +236,7 @@ class ProductVoucherForm(CommonVoucherForm):class Meta:model = Voucher- fields = [- "products",- "apply_once_per_order",- "min_amount_spent",- "min_checkout_items_quantity",- ]+ fields = ["products", "apply_once_per_order", "min_checkout_items_quantity"]def __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)@@ -235,12 +247,7 @@ class ProductVoucherForm(CommonVoucherForm):class CollectionVoucherForm(CommonVoucherForm):class Meta:model = Voucher- fields = [- "collections",- "apply_once_per_order",- "min_amount_spent",- "min_checkout_items_quantity",- ]+ fields = ["collections", "apply_once_per_order", "min_checkout_items_quantity"]labels = {"collections": pgettext_lazy("Collections", "Collections")}def __init__(self, *args, **kwargs):@@ -257,9 +264,4 @@ class CategoryVoucherForm(CommonVoucherForm):class Meta:model = Voucher- fields = [- "categories",- "apply_once_per_order",- "min_amount_spent",- "min_checkout_items_quantity",- ]+ fields = ["categories", "apply_once_per_order", "min_checkout_items_quantity"]diff --git a/saleor/dashboard/order/filters.py b/saleor/dashboard/order/filters.pyindex 42b724a215..8a0a1f44c6 100644--- a/saleor/dashboard/order/filters.py+++ b/saleor/dashboard/order/filters.py@@ -21,7 +21,7 @@ SORT_BY_FIELDS = [("payments__charge_status", "payment_status"),("user__email", "email"),("created", "created"),- ("total_net", "total"),+ ("total_net_amount", "total"),]SORT_BY_FIELDS_LABELS = {@@ -29,7 +29,7 @@ SORT_BY_FIELDS_LABELS = {"payments__charge_status": pgettext_lazy("Order list sorting option", "payment"),"user__email": pgettext_lazy("Order list sorting option", "email"),"created": pgettext_lazy("Order list sorting option", "created"),- "total_net": pgettext_lazy("Order list sorting option", "created"),+ "total_net_amount": pgettext_lazy("Order list sorting option", "created"),}@@ -59,7 +59,9 @@ class OrderFilter(SortedFilterSet):widget=forms.Select,)total_net = RangeFilter(- label=pgettext_lazy("Order list filter label", "Total"), widget=MoneyRangeWidget+ label=pgettext_lazy("Order list filter label", "Total"),+ widget=MoneyRangeWidget,+ field_name="total_net_amount",)sort_by = OrderingFilter(label=pgettext_lazy("Order list filter label", "Sort by"),diff --git a/saleor/dashboard/order/utils.py b/saleor/dashboard/order/utils.pyindex ea284416e3..3a745542fb 100644--- a/saleor/dashboard/order/utils.py+++ b/saleor/dashboard/order/utils.py@@ -80,7 +80,7 @@ def get_prices_of_discounted_products(order, discounted_products):if discounted_products:for line in order:if line.variant.product in discounted_products:- line_prices.extend([line.unit_price_gross] * line.quantity)+ line_prices.extend([line.unit_price_gross_amount] * line.quantity)return line_prices@@ -93,7 +93,7 @@ def get_prices_of_products_in_discounted_collections(order, discounted_collectiocontinueproduct_collections = line.variant.product.collections.all()if set(product_collections).intersection(discounted_collections):- line_prices.extend([line.unit_price_gross] * line.quantity)+ line_prices.extend([line.unit_price_gross_amount] * line.quantity)return line_prices@@ -113,7 +113,7 @@ def get_prices_of_products_in_discounted_categories(order, discounted_categoriescontinueproduct_category = line.variant.product.categoryif product_category in discounted_categories:- line_prices.extend([line.unit_price_gross] * line.quantity)+ line_prices.extend([line.unit_price_gross_amount] * line.quantity)return line_pricesdiff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.pyindex fe94e10dc7..eb8dd59a29 100644--- a/saleor/dashboard/order/views.py+++ b/saleor/dashboard/order/views.py@@ -10,7 +10,7 @@ from django.template.context_processors import csrffrom django.template.response import TemplateResponsefrom django.utils.translation import npgettext_lazy, pgettext_lazyfrom django.views.decorators.http import require_POST-from django_prices.templatetags import prices_i18n+from django_prices.templatetags import pricesfrom ...core.exceptions import InsufficientStockfrom ...core.utils import get_paginator_items@@ -189,7 +189,7 @@ def capture_payment(request, order_pk, payment_pk):if form.is_valid() and form.capture(request.user):msg = pgettext_lazy("Dashboard message related to a payment", "Captured %(amount)s"- ) % {"amount": prices_i18n.amount(amount)}+ ) % {"amount": prices.amount(amount)}events.payment_captured_event(order=order, user=request.user, amount=amount.amount, payment=payment)@@ -216,7 +216,7 @@ def refund_payment(request, order_pk, payment_pk):amount = form.cleaned_data["amount"]msg = pgettext_lazy("Dashboard message related to a payment", "Refunded %(amount)s"- ) % {"amount": prices_i18n.amount(payment.get_captured_amount())}+ ) % {"amount": prices.amount(payment.get_captured_amount())}events.payment_refunded_event(order=order, user=request.user, amount=amount, payment=payment)@@ -733,7 +733,7 @@ def change_fulfillment_tracking(request, order_pk, fulfillment_pk):def ajax_order_shipping_methods_list(request, order_pk):order = get_object_or_404(Order, pk=order_pk)queryset = ShippingMethod.objects.prefetch_related("shipping_zone").order_by(- "name", "price"+ "name", "price_amount")if order.shipping_address:diff --git a/saleor/dashboard/product/filters.py b/saleor/dashboard/product/filters.pyindex 53fd06a2b8..8d35141c5a 100644--- a/saleor/dashboard/product/filters.py+++ b/saleor/dashboard/product/filters.py@@ -14,7 +14,7 @@ from ..widgets import MoneyRangeWidgetPRODUCT_SORT_BY_FIELDS = {"name": pgettext_lazy("Product list sorting option", "name"),- "price": pgettext_lazy("Product type list sorting option", "price"),+ "price_amount": pgettext_lazy("Product type list sorting option", "price"),}PRODUCT_ATTRIBUTE_SORT_BY_FIELDS = {@@ -48,7 +48,7 @@ class ProductFilter(SortedFilterSet):)price = RangeFilter(label=pgettext_lazy("Product list filter label", "Price"),- field_name="price",+ field_name="price_amount",widget=MoneyRangeWidget,)is_published = ChoiceFilter(diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 7ea9e30196..84ae24e186 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -7,9 +7,10 @@ from django.forms.widgets import CheckboxSelectMultiplefrom django.utils.encoding import smart_textfrom django.utils.text import slugifyfrom django.utils.translation import pgettext_lazy+from django_prices.forms import MoneyFieldfrom mptt.forms import TreeNodeChoiceField-from ...core.taxes import include_taxes_in_prices+from ...core.taxes import include_taxes_in_prices, zero_moneyfrom ...core.weight import WeightFieldfrom ...extensions.manager import get_extensions_managerfrom ...product.models import (@@ -37,6 +38,16 @@ from . import ProductBulkActionfrom .widgets import ImagePreviewWidget+def make_money_field():+ return MoneyField(+ available_currencies=settings.AVAILABLE_CURRENCIES,+ min_values=[zero_money()],+ max_digits=settings.DEFAULT_MAX_DIGITS,+ decimal_places=settings.DEFAULT_DECIMAL_PLACES,+ required=False,+ )++class RichTextField(forms.CharField):"""A field for rich text editor, providing backend sanitization."""@@ -233,7 +244,6 @@ class ProductForm(forms.ModelForm, AttributesMixin):tax_rate = forms.ChoiceField(required=False, label=pgettext_lazy("Product tax rate type", "Tax rate"))-category = TreeNodeChoiceField(queryset=Category.objects.all(), label=pgettext_lazy("Category", "Category"))@@ -254,6 +264,7 @@ class ProductForm(forms.ModelForm, AttributesMixin):"if empty, equal to default value used on the ProductType.",),)+ price = make_money_field()model_attributes_field = "attributes"@@ -264,11 +275,12 @@ class ProductForm(forms.ModelForm, AttributesMixin):"product_type","updated_at","description_json",- "minimal_variant_price",+ "price_amount",+ "currency",+ "minimal_variant_price_amount",]labels = {"name": pgettext_lazy("Item name", "Name"),- "price": pgettext_lazy("Currency amount", "Price"),"publication_date": pgettext_lazy("Availability date", "Publish product on"),@@ -321,6 +333,10 @@ class ProductForm(forms.ModelForm, AttributesMixin):"placeholder"] = product_type.weight.value+ if self.instance.pk is not None:+ self.fields["price"].initial = self.instance.price+ self.fields["price"].required = True+def clean_seo_description(self):seo_description = prepare_seo_description(seo_description=self.cleaned_data["seo_description"],@@ -332,8 +348,15 @@ class ProductForm(forms.ModelForm, AttributesMixin):def save(self, commit=True):attributes = self.get_saved_attributes()self.instance.attributes = attributes++ price = self.cleaned_data["price"]+ if not price.currency:+ price.currency = settings.DEFAULT_CURRENCY+ self.instance.price = price+instance = super().save()instance.collections.clear()+for collection in self.cleaned_data["collections"]:instance.collections.add(collection)update_product_minimal_variant_price_task.delay(instance.pk)@@ -341,6 +364,7 @@ class ProductForm(forms.ModelForm, AttributesMixin):class ProductVariantForm(forms.ModelForm, AttributesMixin):+ MONEY_FIELDS = ("price_override", "cost_price")model_attributes_field = "attributes"weight = WeightField(required=False,@@ -351,6 +375,8 @@ class ProductVariantForm(forms.ModelForm, AttributesMixin):"If empty, weight from Product or ProductType will be used.",),)+ price_override = make_money_field()+ cost_price = make_money_field()class Meta:model = ProductVariant@@ -364,9 +390,7 @@ class ProductVariantForm(forms.ModelForm, AttributesMixin):]labels = {"sku": pgettext_lazy("SKU", "SKU"),- "price_override": pgettext_lazy("Override price", "Selling price override"),"quantity": pgettext_lazy("Integer number", "Number in stock"),- "cost_price": pgettext_lazy("Currency amount", "Cost price"),"track_inventory": pgettext_lazy("Track inventory field", "Track inventory"),@@ -414,16 +438,32 @@ class ProductVariantForm(forms.ModelForm, AttributesMixin):or self.instance.product.product_type.weight.value)+ if self.instance.pk is not None:+ for field in self.MONEY_FIELDS:+ self.fields[field].initial = getattr(self.instance, field)+def save(self, commit=True):+ assert commit is True, "Commit is required"+attributes = self.get_saved_attributes()self.instance.attributes = attributesattrs = self.instance.product.product_type.variant_attributes.prefetch_related("values__translations")self.instance.name = get_name_from_attributes(self.instance, attrs)- instance = super().save(commit=commit)- update_product_minimal_variant_price_task.delay(instance.product_id)- return instance++ for field in self.MONEY_FIELDS:+ money_input = self.cleaned_data[field]+ if money_input is not None:+ if not money_input.currency:+ money_input.currency = settings.DEFAULT_CURRENCY+ setattr(self.instance, field, money_input)++ super().save(commit=commit)++ # Note: save must always be called with commit=True+ update_product_minimal_variant_price_task.delay(self.instance.product_id)+ return self.instanceclass CachingModelChoiceIterator(ModelChoiceIterator):diff --git a/saleor/dashboard/shipping/filters.py b/saleor/dashboard/shipping/filters.pyindex d9e99a0233..3478ce997f 100644--- a/saleor/dashboard/shipping/filters.py+++ b/saleor/dashboard/shipping/filters.py@@ -4,6 +4,7 @@ from django_filters import CharFilter, ChoiceFilter, OrderingFilter, RangeFilterfrom ...core.filters import SortedFilterSetfrom ...core.i18n import COUNTRY_CODE_CHOICESfrom ...shipping.models import ShippingZone+from ..widgets import MoneyRangeWidgetSORT_BY_FIELDS = {"name": pgettext_lazy("Group list sorting option", "name")}@@ -15,7 +16,8 @@ class ShippingZoneFilter(SortedFilterSet):)price = RangeFilter(label=pgettext_lazy("Shipping zones list filter label", "Price range"),- field_name="shipping_methods__price",+ widget=MoneyRangeWidget,+ field_name="shipping_methods__price_amount",)country = ChoiceFilter(label=pgettext_lazy("Shipping zones filter label", "Country"),diff --git a/saleor/dashboard/shipping/forms.py b/saleor/dashboard/shipping/forms.pyindex 84f6a06551..b835656208 100644--- a/saleor/dashboard/shipping/forms.py+++ b/saleor/dashboard/shipping/forms.py@@ -1,5 +1,8 @@from django import forms+from django.conf import settingsfrom django.utils.translation import pgettext_lazy+from django_prices.forms import MoneyField+from prices import Moneyfrom ...account.i18n import COUNTRY_CHOICESfrom ...core.weight import WeightField@@ -130,6 +133,12 @@ class ShippingZoneForm(forms.ModelForm):class ShippingMethodForm(forms.ModelForm):+ price = MoneyField(+ required=False,+ label=pgettext_lazy("Currency amount", "Price"),+ available_currencies=settings.AVAILABLE_CURRENCIES,+ )+class Meta:model = ShippingMethodfields = ["name", "price"]@@ -146,6 +155,26 @@ class ShippingMethodForm(forms.ModelForm):class PriceShippingMethodForm(forms.ModelForm):+ price = MoneyField(+ required=False,+ label=pgettext_lazy("Currency amount", "Price"),+ available_currencies=settings.AVAILABLE_CURRENCIES,+ )+ minimum_order_price = MoneyField(+ required=False,+ label=pgettext_lazy(+ "Minimum order price to use this shipping method", "Minimum order price"+ ),+ available_currencies=settings.AVAILABLE_CURRENCIES,+ )+ maximum_order_price = MoneyField(+ required=False,+ label=pgettext_lazy(+ "Maximum order price to use this order", "Maximum order price"+ ),+ available_currencies=settings.AVAILABLE_CURRENCIES,+ )+class Meta(ShippingMethodForm.Meta):labels = {"minimum_order_price": pgettext_lazy(@@ -159,6 +188,11 @@ class PriceShippingMethodForm(forms.ModelForm):fields = ["name", "price", "minimum_order_price", "maximum_order_price"]def __init__(self, *args, **kwargs):+ instance = kwargs["instance"]+ initial = kwargs.setdefault("initial", {})+ initial.setdefault("price", instance.price)+ initial.setdefault("minimum_order_price", instance.minimum_order_price)+ initial.setdefault("maximum_order_price", instance.maximum_order_price)super().__init__(*args, **kwargs)self.fields["maximum_order_price"].widget.attrs["placeholder"] = pgettext_lazy("Placeholder for maximum order price set to unlimited", "No limit"@@ -183,6 +217,15 @@ class PriceShippingMethodForm(forms.ModelForm):)return data+ def save(self, commit=True):+ for k, v in self.cleaned_data.items():+ if not isinstance(v, Money):+ continue+ if not v.currency:+ v.currency = settings.DEFAULT_CURRENCY+ setattr(self.instance, k, v)+ return super().save(commit=commit)+class WeightShippingMethodForm(forms.ModelForm):minimum_order_weight = WeightField(@@ -197,6 +240,9 @@ class WeightShippingMethodForm(forms.ModelForm):"Maximum order weight to use this shipping method", "Maximum order weight"),)+ price = MoneyField(+ required=False, available_currencies=settings.AVAILABLE_CURRENCIES+ )class Meta(ShippingMethodForm.Meta):fields = ["name", "price", "minimum_order_weight", "maximum_order_weight"]diff --git a/saleor/dashboard/shipping/views.py b/saleor/dashboard/shipping/views.pyindex 997e6bcf2c..1c9105ac81 100644--- a/saleor/dashboard/shipping/views.py+++ b/saleor/dashboard/shipping/views.py@@ -106,7 +106,7 @@ def shipping_method_add(request, shipping_zone_pk, type):form = get_shipping_form(shipping_method.type)form = form(request.POST or None, instance=shipping_method)if form.is_valid():- shipping_method = form.save()+ form.save()msg = pgettext_lazy("Dashboard message", "Added shipping method for %(zone_name)s shipping zone") % {"zone_name": shipping_zone}diff --git a/saleor/dashboard/templatetags/orders.py b/saleor/dashboard/templatetags/orders.pyindex 91f5a1001f..05f66e83ab 100644--- a/saleor/dashboard/templatetags/orders.py+++ b/saleor/dashboard/templatetags/orders.py@@ -1,7 +1,7 @@from django.conf import settingsfrom django.template import Libraryfrom django.utils.translation import npgettext_lazy, pgettext_lazy-from django_prices.templatetags import prices_i18n+from django_prices.templatetags import pricesfrom prices import Moneyfrom ...order import events@@ -59,15 +59,13 @@ def display_order_event(order_event: OrderEvent):amount = get_money_from_params(params["amount"])return pgettext_lazy("Dashboard message related to an order",- "Successfully refunded: %(amount)s"- % {"amount": prices_i18n.amount(amount)},+ "Successfully refunded: %(amount)s" % {"amount": prices.amount(amount)},)if event_type == events.OrderEvents.PAYMENT_CAPTURED:amount = get_money_from_params(params["amount"])return pgettext_lazy("Dashboard message related to an order",- "Successfully captured: %(amount)s"- % {"amount": prices_i18n.amount(amount)},+ "Successfully captured: %(amount)s" % {"amount": prices.amount(amount)},)if event_type == events.OrderEvents.ORDER_MARKED_AS_PAID:return pgettext_lazy(diff --git a/saleor/dashboard/widgets.py b/saleor/dashboard/widgets.pyindex 9ec9db7a9b..8de886ef32 100644--- a/saleor/dashboard/widgets.py+++ b/saleor/dashboard/widgets.py@@ -2,7 +2,6 @@ from django import formsfrom django.conf import settingsfrom django.forms import Textarea, TextInputfrom django_filters import widgets-from django_prices.widgets import MoneyInputfrom ..account.widgets import PhonePrefixWidget as StorefrontPhonePrefixWidget@@ -17,7 +16,7 @@ class DateRangeWidget(widgets.DateRangeWidget):class MoneyRangeWidget(widgets.RangeWidget):def __init__(self, attrs=None):self.currency = getattr(settings, "DEFAULT_CURRENCY")- money_widgets = (MoneyInput(self.currency), MoneyInput(self.currency))+ money_widgets = (forms.NumberInput(), forms.NumberInput())# pylint: disable=bad-super-callsuper(widgets.RangeWidget, self).__init__(money_widgets, attrs)diff --git a/saleor/discount/migrations/0002_voucher.py b/saleor/discount/migrations/0002_voucher.pyindex 3e281c21d1..977dde877e 100644--- a/saleor/discount/migrations/0002_voucher.py+++ b/saleor/discount/migrations/0002_voucher.py@@ -5,7 +5,6 @@ from __future__ import unicode_literalsimport datetimeimport django.db.models.deletion-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -76,12 +75,8 @@ class Migration(migrations.Migration):("apply_to", models.CharField(blank=True, max_length=20, null=True)),("limit",- django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),(diff --git a/saleor/discount/migrations/0004_auto_20170206_0407.py b/saleor/discount/migrations/0004_auto_20170206_0407.pyindex 2bae7cfae0..56ca2d62b6 100644--- a/saleor/discount/migrations/0004_auto_20170206_0407.py+++ b/saleor/discount/migrations/0004_auto_20170206_0407.py@@ -3,7 +3,6 @@from __future__ import unicode_literalsimport django.db.models.deletion-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -78,9 +77,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="voucher",name="limit",- field=django_prices.models.MoneyField(+ field=models.DecimalField(blank=True,- currency=settings.DEFAULT_CURRENCY,decimal_places=2,max_digits=12,null=True,diff --git a/saleor/discount/migrations/0007_auto_20180108_0814.py b/saleor/discount/migrations/0007_auto_20180108_0814.pyindex fb57119d44..1e9719cfe3 100644--- a/saleor/discount/migrations/0007_auto_20180108_0814.py+++ b/saleor/discount/migrations/0007_auto_20180108_0814.py@@ -5,7 +5,6 @@ from __future__ import unicode_literalsimport datetimeimport django.db.models.deletion-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -84,12 +83,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="voucher",name="limit",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AlterField(diff --git a/saleor/discount/migrations/0017_django_price_2.py b/saleor/discount/migrations/0017_django_price_2.pynew file mode 100644index 0000000000..fa10bd5b8b--- /dev/null+++ b/saleor/discount/migrations/0017_django_price_2.py@@ -0,0 +1,22 @@+# Generated by Django 2.2.4 on 2019-08-14 09:13++from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [("discount", "0016_auto_20190716_0330")]++ operations = [+ migrations.RenameField(+ model_name="voucher",+ old_name="min_amount_spent",+ new_name="min_spent_amount",+ ),+ migrations.AddField(+ model_name="voucher",+ name="currency",+ field=models.CharField(default=settings.DEFAULT_CURRENCY, max_length=10),+ ),+ ]diff --git a/saleor/discount/models.py b/saleor/discount/models.pyindex 467097aa45..6ada6a2b4f 100644--- a/saleor/discount/models.py+++ b/saleor/discount/models.py@@ -8,7 +8,7 @@ from django.utils import timezonefrom django.utils.translation import pgettext, pgettext_lazyfrom django_countries.fields import CountryFieldfrom django_prices.models import MoneyField-from django_prices.templatetags.prices_i18n import amount+from django_prices.templatetags.prices import amountfrom prices import Money, fixed_discount, percentage_discountfrom ..core.utils.translations import TranslationProxy@@ -20,13 +20,13 @@ class NotApplicable(ValueError):The error is raised if the order value is below the minimum requiredprice or the order quantity is below the minimum quantity of items.- Minimum price will be available as the `min_amount_spent` attribute.+ Minimum price will be available as the `min_spent` attribute.Minimum quantity will be available as the `min_checkout_items_quantity` attribute."""- def __init__(self, msg, min_amount_spent=None, min_checkout_items_quantity=None):+ def __init__(self, msg, min_spent=None, min_checkout_items_quantity=None):super().__init__(msg)- self.min_amount_spent = min_amount_spent+ self.min_spent = min_spentself.min_checkout_items_quantity = min_checkout_items_quantity@@ -58,6 +58,7 @@ class Voucher(models.Model):# individually to every itemapply_once_per_order = models.BooleanField(default=False)apply_once_per_customer = models.BooleanField(default=False)+discount_value_type = models.CharField(max_length=10,choices=DiscountValueType.CHOICES,@@ -67,15 +68,18 @@ class Voucher(models.Model):max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,)+ discount = MoneyField(amount_field="discount_value", currency_field="currency")+# not mandatory fields, usage depends on typecountries = CountryField(multiple=True, blank=True)- min_amount_spent = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ currency = models.CharField(max_length=10, default=settings.DEFAULT_CURRENCY)+ min_spent_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- null=True,blank=True,+ null=True,)+ min_spent = MoneyField(amount_field="min_spent_amount", currency_field="currency")min_checkout_items_quantity = models.PositiveIntegerField(null=True, blank=True)products = models.ManyToManyField("product.Product", blank=True)collections = models.ManyToManyField("product.Collection", blank=True)@@ -132,23 +136,22 @@ class Voucher(models.Model):return partial(percentage_discount, percentage=self.discount_value)raise NotImplementedError("Unknown discount type")- def get_discount_amount_for(self, price):+ def get_discount_amount_for(self, price: Money):discount = self.get_discount()after_discount = discount(price)if after_discount.amount < 0:return pricereturn price - after_discount- def validate_min_amount_spent(self, value):- min_amount_spent = self.min_amount_spent- if min_amount_spent and value < min_amount_spent:+ def validate_min_spent(self, value: Money):+ min_spent = self.min_spent+ if min_spent and value < min_spent:msg = pgettext("Voucher not applicable","This offer is only valid for orders over %(amount)s.",)raise NotApplicable(- msg % {"amount": amount(min_amount_spent)},- min_amount_spent=min_amount_spent,+ msg % {"amount": amount(min_spent)}, min_spent=min_spent)def validate_min_checkout_items_quantity(self, quantity):diff --git a/saleor/discount/templatetags/voucher.py b/saleor/discount/templatetags/voucher.pyindex b6dc622bc5..02a1a6a031 100644--- a/saleor/discount/templatetags/voucher.py+++ b/saleor/discount/templatetags/voucher.py@@ -1,5 +1,5 @@from django import template-from django_prices.templatetags import prices_i18n+from django_prices.templatetags import pricesfrom prices import Moneyregister = template.Library()@@ -8,4 +8,4 @@ register = template.Library()@register.simple_tagdef discount_as_negative(discount, html=False):zero = Money(0, discount.currency)- return prices_i18n.amount(zero - discount, "html" if html else "text")+ return prices.amount(zero - discount, "html" if html else "text")diff --git a/saleor/discount/utils.py b/saleor/discount/utils.pyindex e4b3182e43..7d3d913f33 100644--- a/saleor/discount/utils.py+++ b/saleor/discount/utils.py@@ -100,7 +100,7 @@ def validate_voucher_in_order(order):def validate_voucher(voucher, total_price, quantity, customer_email):- voucher.validate_min_amount_spent(total_price)+ voucher.validate_min_spent(total_price)voucher.validate_min_checkout_items_quantity(quantity)if voucher.apply_once_per_customer:voucher.validate_once_per_customer(customer_email)diff --git a/saleor/extensions/manager.py b/saleor/extensions/manager.pyindex b32878e585..63d033d276 100644--- a/saleor/extensions/manager.py+++ b/saleor/extensions/manager.py@@ -115,7 +115,7 @@ class ExtensionsManager:"calculate_checkout_line_total", default_value, checkout_line, discounts)- def calculate_order_line_unit(self, order_line: "OrderLine"):+ def calculate_order_line_unit(self, order_line: "OrderLine") -> TaxedMoney:unit_price = order_line.unit_pricedefault_value = quantize_price(unit_price, unit_price.currency)return self.__run_method_on_plugins(diff --git a/saleor/extensions/plugins/avatax/__init__.py b/saleor/extensions/plugins/avatax/__init__.pyindex 8a3290457b..1407130c44 100644--- a/saleor/extensions/plugins/avatax/__init__.py+++ b/saleor/extensions/plugins/avatax/__init__.py@@ -255,16 +255,16 @@ def get_order_lines_data(order: "Order") -> List[Dict[str, str]]:append_line_to_data(data=data,quantity=line.quantity,- amount=line.unit_price_net.amount * line.quantity,+ amount=line.unit_price_net_amount * line.quantity,tax_code=tax_code,item_code=line.variant.sku,description=line.variant.product.plain_text_description,)- if order.discount_amount and order.discount_amount.amount:+ if order.discount_amount and order.discount_amount:append_line_to_data(data=data,quantity=1,- amount=order.discount_amount.amount * -1,+ amount=order.discount_amount * -1,tax_code=COMMON_DISCOUNT_VOUCHER_CODE,item_code="Voucher",description=order.discount_name,diff --git a/saleor/extensions/plugins/avatax/plugin.py b/saleor/extensions/plugins/avatax/plugin.pyindex 5295f6d07b..fad8b4073f 100644--- a/saleor/extensions/plugins/avatax/plugin.py+++ b/saleor/extensions/plugins/avatax/plugin.py@@ -157,7 +157,7 @@ class AvataxPlugin(BasePlugin):total_gross = Money(amount=total_net + tax, currency=currency)total_net = Money(amount=total_net, currency=currency)total = TaxedMoney(net=total_net, gross=total_gross)- voucher_amount = checkout.discount_amount+ voucher_amount = checkout.discountif voucher_amount:total -= voucher_amountreturn max(total, zero_taxed_money(total.currency))diff --git a/saleor/extensions/plugins/vatlayer/plugin.py b/saleor/extensions/plugins/vatlayer/plugin.pyindex 39abdae6a5..185a7d58e9 100644--- a/saleor/extensions/plugins/vatlayer/plugin.py+++ b/saleor/extensions/plugins/vatlayer/plugin.py@@ -75,7 +75,7 @@ class VatlayerPlugin(BasePlugin):return (self.calculate_checkout_subtotal(checkout, discounts, previous_value)+ self.calculate_checkout_shipping(checkout, discounts, taxed_zero)- - checkout.discount_amount+ - checkout.discount)def calculate_checkout_subtotal(@@ -187,7 +187,7 @@ class VatlayerPlugin(BasePlugin):country = address.country if address else Nonevariant = order_line.variantreturn self.__apply_taxes_to_product(- variant.product, order_line.unit_price_net, country+ variant.product, order_line.unit_price, country)def get_tax_rate_type_choices(diff --git a/saleor/giftcard/migrations/0001_initial.py b/saleor/giftcard/migrations/0001_initial.pyindex cbc8cd78da..e0722d3ddb 100644--- a/saleor/giftcard/migrations/0001_initial.py+++ b/saleor/giftcard/migrations/0001_initial.py@@ -3,7 +3,6 @@import datetimeimport django.db.models.deletion-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -35,15 +34,11 @@ class Migration(migrations.Migration):("is_active", models.BooleanField(default=True)),("initial_balance",- django_prices.models.MoneyField(- currency="USD", decimal_places=2, max_digits=12- ),+ models.DecimalField(decimal_places=2, max_digits=12),),("current_balance",- django_prices.models.MoneyField(- currency="USD", decimal_places=2, max_digits=12- ),+ models.DecimalField(decimal_places=2, max_digits=12),),("user",diff --git a/saleor/giftcard/migrations/0002_auto_20190814_0413.py b/saleor/giftcard/migrations/0002_auto_20190814_0413.pynew file mode 100644index 0000000000..1743eede95--- /dev/null+++ b/saleor/giftcard/migrations/0002_auto_20190814_0413.py@@ -0,0 +1,27 @@+# Generated by Django 2.2.4 on 2019-08-14 09:13++from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [("giftcard", "0001_initial")]++ operations = [+ migrations.RenameField(+ model_name="giftcard",+ old_name="current_balance",+ new_name="current_balance_amount",+ ),+ migrations.RenameField(+ model_name="giftcard",+ old_name="initial_balance",+ new_name="initial_balance_amount",+ ),+ migrations.AddField(+ model_name="giftcard",+ name="currency",+ field=models.CharField(default=settings.DEFAULT_CURRENCY, max_length=3),+ ),+ ]diff --git a/saleor/giftcard/models.py b/saleor/giftcard/models.pyindex e440cab8ae..947f0d7536 100644--- a/saleor/giftcard/models.py+++ b/saleor/giftcard/models.py@@ -30,16 +30,24 @@ class GiftCard(models.Model):end_date = models.DateField(null=True, blank=True)last_used_on = models.DateTimeField(null=True, blank=True)is_active = models.BooleanField(default=True)- initial_balance = MoneyField(- currency=settings.DEFAULT_CURRENCY,++ currency = models.CharField(max_length=3, default=settings.DEFAULT_CURRENCY)++ initial_balance_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,)- current_balance = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ initial_balance = MoneyField(+ amount_field="initial_balance_amount", currency_field="currency"+ )++ current_balance_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,)+ current_balance = MoneyField(+ amount_field="current_balance_amount", currency_field="currency"+ )objects = GiftCardQueryset.as_manager()diff --git a/saleor/graphql/account/filters.py b/saleor/graphql/account/filters.pyindex b2ef7f00af..beae8798ee 100644--- a/saleor/graphql/account/filters.py+++ b/saleor/graphql/account/filters.py@@ -18,7 +18,7 @@ def filter_date_joined(qs, _, value):def filter_money_spent(qs, _, value):- qs = qs.annotate(money_spent=Sum("orders__total_gross"))+ qs = qs.annotate(money_spent=Sum("orders__total_gross_amount"))money_spent_lte, money_spent_gte = value.get("lte"), value.get("gte")if money_spent_lte:qs = qs.filter(money_spent__lte=money_spent_lte)diff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.pyindex fa9b3355e9..61713fab0b 100644--- a/saleor/graphql/checkout/types.py+++ b/saleor/graphql/checkout/types.py@@ -9,7 +9,7 @@ from ...core.taxes import zero_taxed_moneyfrom ..core.connection import CountableDjangoObjectTypefrom ..core.resolvers import resolve_meta, resolve_private_metafrom ..core.types.meta import MetadataObjectType-from ..core.types.money import TaxedMoney+from ..core.types.money import Money, TaxedMoneyfrom ..giftcard.types import GiftCardfrom ..payment.enums import PaymentGatewayEnumfrom ..shipping.types import ShippingMethod@@ -88,6 +88,7 @@ class Checkout(MetadataObjectType, CountableDjangoObjectType):"shipping costs, and discounts included."),)+ discount_amount = graphene.Field(Money, deprecation_reason="Use discount instead.")class Meta:only_fields = [@@ -106,6 +107,7 @@ class Checkout(MetadataObjectType, CountableDjangoObjectType):"translated_discount_name","user","voucher_code",+ "discount",]description = "Checkout object"model = models.Checkout@@ -165,9 +167,13 @@ class Checkout(MetadataObjectType, CountableDjangoObjectType):@staticmethod@permission_required("order.manage_orders")- def resolve_private_meta(root, _info):+ def resolve_private_meta(root: models.Checkout, _info):return resolve_private_meta(root, _info)@staticmethod- def resolve_meta(root, _info):+ def resolve_meta(root: models.Checkout, _info):return resolve_meta(root, _info)++ @staticmethod+ def resolve_discount_amount(root: models.Checkout, _info):+ return root.discountdiff --git a/saleor/graphql/core/types/money.py b/saleor/graphql/core/types/money.pyindex 03ba2ccc8c..43decac7a0 100644--- a/saleor/graphql/core/types/money.py+++ b/saleor/graphql/core/types/money.py@@ -1,5 +1,5 @@import graphene-from django_prices.templatetags import prices_i18n+from django_prices.templatetags import pricesfrom ..enums import TaxRateType@@ -16,7 +16,7 @@ class Money(graphene.ObjectType):@staticmethoddef resolve_localized(root, _info):- return prices_i18n.amount(root)+ return prices.amount(root)class MoneyRange(graphene.ObjectType):diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.pyindex 458d3b0da1..8236045512 100644--- a/saleor/graphql/discount/mutations.py+++ b/saleor/graphql/discount/mutations.py@@ -83,10 +83,11 @@ class BaseDiscountCatalogueMutation(BaseMutation):class VoucherInput(graphene.InputObjectType):type = VoucherTypeEnum(description=(- "Voucher type: PRODUCT, CATEGORY SHIPPING or ENTIRE_ORDER. "- "Deprecated fields: "- "PRODUCT, COLLECTION, CATEGORY use SPECIFIC_PRODUCT instead. "- "VALUE use ENTIRE_ORDER instead."+ "Voucher type: PRODUCT, CATEGORY SHIPPING or ENTIRE_ORDER.\n"+ "Deprecated fields:\n"+ "\t1. PRODUCT, COLLECTION, CATEGORY use SPECIFIC_PRODUCT instead. "+ "VALUE use ENTIRE_ORDER instead.\n"+ "\t2. minAmountSpent use minSpentAmount instead"))name = graphene.String(description="Voucher name.")@@ -115,6 +116,12 @@ class VoucherInput(graphene.InputObjectType):name="categories",)min_amount_spent = Decimal(+ description=(+ "Deprecated: use minSpentAmount instead."+ "Min purchase amount required to apply the voucher."+ )+ )+ min_spent_amount = Decimal(description="Min purchase amount required to apply the voucher.")min_checkout_items_quantity = graphene.Int(@@ -156,6 +163,11 @@ class VoucherCreate(ModelMutation):voucher_type = data.get("type", None)if voucher_type == VoucherTypeEnum.VALUE:data["type"] = VoucherTypeEnum.ENTIRE_ORDER.value++ min_spent_amount = data.pop("min_amount_spent", None)+ if min_spent_amount is not None:+ data["min_spent_amount"] = min_spent_amount+cleaned_input = super().clean_input(info, instance, data)return cleaned_inputdiff --git a/saleor/graphql/discount/types.py b/saleor/graphql/discount/types.pyindex d1232366d1..b579b13639 100644--- a/saleor/graphql/discount/types.py+++ b/saleor/graphql/discount/types.py@@ -3,9 +3,9 @@ import graphene_django_optimizer as gql_optimizerfrom graphene import relayfrom ...discount import models+from ..core import typesfrom ..core.connection import CountableDjangoObjectTypefrom ..core.fields import PrefetchingConnectionField-from ..core.types import CountryDisplayfrom ..product.types import Category, Collection, Productfrom ..translations.enums import LanguageCodeEnumfrom ..translations.resolvers import resolve_translation@@ -84,7 +84,7 @@ class Voucher(CountableDjangoObjectType):model_field="products",)countries = graphene.List(- CountryDisplay,+ types.CountryDisplay,description="List of countries available for the shipping voucher.",)translation = graphene.Field(@@ -102,6 +102,9 @@ class Voucher(CountableDjangoObjectType):required=True,)type = VoucherTypeEnum(description="Determines a type of voucher", required=True)+ min_amount_spent = graphene.Field(+ types.Money, deprecation_reason="Use the minAmount field instead."+ )class Meta:description = """@@ -116,7 +119,7 @@ class Voucher(CountableDjangoObjectType):"discount_value_type","end_date","id",- "min_amount_spent",+ "min_spent","min_checkout_items_quantity","name","start_date",@@ -142,6 +145,10 @@ class Voucher(CountableDjangoObjectType):@staticmethoddef resolve_countries(root: models.Voucher, *_args, **_kwargs):return [- CountryDisplay(code=country.code, country=country.name)+ types.CountryDisplay(code=country.code, country=country.name)for country in root.countries]++ @staticmethod+ def resolve_min_amount_spent(root: models.Voucher, *_args, **_kwargs):+ return root.min_spentdiff --git a/saleor/graphql/giftcard/mutations.py b/saleor/graphql/giftcard/mutations.pyindex f603650117..348e9d15e8 100644--- a/saleor/graphql/giftcard/mutations.py+++ b/saleor/graphql/giftcard/mutations.py@@ -52,8 +52,8 @@ class GiftCardCreate(ModelMutation):cleaned_input = super().clean_input(info, instance, data)balance = cleaned_input.get("balance", None)if balance:- cleaned_input["current_balance"] = balance- cleaned_input["initial_balance"] = balance+ cleaned_input["current_balance_amount"] = balance+ cleaned_input["initial_balance_amount"] = balanceuser_email = data.get("user_email", None)if user_email:try:diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.pyindex 8cbf7ed55f..98442d5aa6 100644--- a/saleor/graphql/order/mutations/orders.py+++ b/saleor/graphql/order/mutations/orders.py@@ -154,9 +154,10 @@ class OrderUpdateShipping(BaseMutation):order.shipping_method_name = Noneorder.save(update_fields=[+ "currency","shipping_method",- "shipping_price_net",- "shipping_price_gross",+ "shipping_price_net_amount",+ "shipping_price_gross_amount","shipping_method_name",])@@ -176,10 +177,11 @@ class OrderUpdateShipping(BaseMutation):order.shipping_method_name = method.nameorder.save(update_fields=[+ "currency","shipping_method","shipping_method_name",- "shipping_price_net",- "shipping_price_gross",+ "shipping_price_net_amount",+ "shipping_price_gross_amount",])# Post-process the resultsdiff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex 824a4d29c2..4e2a77af2c 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -326,6 +326,9 @@ class Order(CountableDjangoObjectType):is_shipping_required = graphene.Boolean(description="Returns True, if order requires shipping.", required=True)+ discount_amount = graphene.Field(+ Money, description="Deprecated: use discount instead.", required=True+ )class Meta:description = "Represents an order in the shop."@@ -335,7 +338,7 @@ class Order(CountableDjangoObjectType):"billing_address","created","customer_note",- "discount_amount",+ "discount","discount_name","display_gross_prices","gift_cards",@@ -468,3 +471,7 @@ class Order(CountableDjangoObjectType):@staticmethoddef resolve_gift_cards(root: models.Order, _info):return root.gift_cards.all()++ @staticmethod+ def resolve_discount_amount(root: models.Order, _info):+ return root.discountdiff --git a/saleor/graphql/product/enums.py b/saleor/graphql/product/enums.pyindex ac3a317961..571b8e9106 100644--- a/saleor/graphql/product/enums.py+++ b/saleor/graphql/product/enums.py@@ -25,8 +25,8 @@ class StockAvailability(graphene.Enum):class ProductOrderField(graphene.Enum):NAME = "name"- PRICE = "price"- MINIMAL_PRICE = "minimal_variant_price"+ PRICE = "price_amount"+ MINIMAL_PRICE = "minimal_variant_price_amount"DATE = "updated_at"@propertydiff --git a/saleor/graphql/product/filters.py b/saleor/graphql/product/filters.pyindex 647b393e0a..9e3a9b2278 100644--- a/saleor/graphql/product/filters.py+++ b/saleor/graphql/product/filters.py@@ -68,9 +68,9 @@ def filter_products_by_attributes(qs, filter_value):def filter_products_by_price(qs, price_lte=None, price_gte=None):if price_lte:- qs = qs.filter(price__lte=price_lte)+ qs = qs.filter(price_amount__lte=price_lte)if price_gte:- qs = qs.filter(price__gte=price_gte)+ qs = qs.filter(price_amount__gte=price_gte)return qs@@ -78,9 +78,9 @@ def filter_products_by_minimal_price(qs, minimal_price_lte=None, minimal_price_gte=None):if minimal_price_lte:- qs = qs.filter(minimal_variant_price__lte=minimal_price_lte)+ qs = qs.filter(minimal_variant_price_amount__lte=minimal_price_lte)if minimal_price_gte:- qs = qs.filter(minimal_variant_price__gte=minimal_price_gte)+ qs = qs.filter(minimal_variant_price_amount__gte=minimal_price_gte)return qs@@ -187,9 +187,13 @@ class ProductFilter(django_filters.FilterSet):is_published = django_filters.BooleanFilter()collections = GlobalIDMultipleChoiceFilter(method=filter_collections)categories = GlobalIDMultipleChoiceFilter(method=filter_categories)- price = ObjectTypeFilter(input_class=PriceRangeInput, method=filter_price)+ price = ObjectTypeFilter(+ input_class=PriceRangeInput, method=filter_price, field_name="price_amount"+ )minimal_price = ObjectTypeFilter(- input_class=PriceRangeInput, method=filter_minimal_price+ input_class=PriceRangeInput,+ method=filter_minimal_price,+ field_name="minimal_price_amount",)attributes = ListObjectTypeFilter(input_class=AttributeInput, method=filter_attributesdiff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex b57ecf18fa..ce6604e5a3 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -439,8 +439,7 @@ class ProductInput(graphene.InputObjectType):)base_price = Decimal(description="Product price.")tax_rate = TaxRateType(- description="Tax rate.",- deprecation_reason=("taxRate is deprecated, Use taxCode"),+ description="Tax rate.", deprecation_reason="taxRate is deprecated, Use taxCode")tax_code = graphene.String(description="Tax rate for enabled tax gateway")seo = SeoInput(description="Search engine optimization fields.")@@ -498,10 +497,10 @@ class ProductCreate(ModelMutation):# from the schema, only "basePrice" should be used here.price = data.get("base_price", data.get("price"))if price is not None:- cleaned_input["price"] = price- if instance.minimal_variant_price is None:+ cleaned_input["price_amount"] = price+ if instance.minimal_variant_price_amount is None:# Set the default "minimal_variant_price" to the "price"- cleaned_input["minimal_variant_price"] = price+ cleaned_input["minimal_variant_price_amount"] = price# FIXME tax_rate logic should be dropped after we remove tax_rate from inputtax_rate = cleaned_input.pop("tax_rate", "")@@ -657,8 +656,21 @@ class ProductVariantInput(graphene.InputObjectType):required=False,description="List of attributes specific to this variant.",)- cost_price = Decimal(description="Cost price of the variant.")- price_override = Decimal(description="Special price of the particular variant.")+ cost_price = Decimal(+ description=(+ "Deprecated: use costPriceAmount instead.\n" "Cost price of the variant."+ )+ )+ cost_price_amount = Decimal(description="Cost price of the variant.")+ price_override = Decimal(+ description=(+ "Deprecated: use priceOverrideAmount instead.\n"+ "Special price of the particular variant."+ )+ )+ price_override_amount = Decimal(+ description="Special price of the particular variant."+ )sku = graphene.String(description="Stock keeping unit.")quantity = graphene.Int(description="The total quantity of this variant available for sale."@@ -728,6 +740,15 @@ class ProductVariantCreate(ModelMutation):@classmethoddef clean_input(cls, info, instance, data):++ cost_price_amount = data.pop("cost_price", None)+ if cost_price_amount is not None:+ data["cost_price_amount"] = cost_price_amount++ price_override_amount = data.pop("price_override", None)+ if price_override_amount is not None:+ data["price_override_amount"] = price_override_amount+cleaned_input = super().clean_input(info, instance, data)# Attributes are provided as list of `AttributeValueInput` objects.@@ -747,6 +768,7 @@ class ProductVariantCreate(ModelMutation):raise ValidationError({"attributes": str(e)})else:cleaned_input["attributes"] = attributes+return cleaned_input@classmethoddiff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex 0836dcd7e1..9a7d2e9288 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -301,7 +301,7 @@ class ProductVariant(CountableDjangoObjectType, MetadataObjectType):@staticmethod@gql_optimizer.resolver_hints(- prefetch_related=("product",), only=["price_override"]+ prefetch_related=("product",), only=["price_override_amount", "currency"])def resolve_pricing(root: models.ProductVariant, info):context = info.context@@ -527,7 +527,7 @@ class Product(CountableDjangoObjectType, MetadataObjectType):@staticmethod@gql_optimizer.resolver_hints(prefetch_related=("variants", "collections"),- only=["publication_date", "charge_taxes", "price", "meta"],+ only=["publication_date", "charge_taxes", "price_amount", "currency", "meta"],)def resolve_pricing(root: models.Product, info):context = info.context@@ -554,7 +554,7 @@ class Product(CountableDjangoObjectType, MetadataObjectType):@staticmethod@gql_optimizer.resolver_hints(prefetch_related=("variants", "collections"),- only=["publication_date", "charge_taxes", "price", "meta"],+ only=["publication_date", "charge_taxes", "price_amount", "currency", "meta"],)def resolve_price(root: models.Product, info):price_range = root.get_price_range(info.context.discounts)diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex c23fe6a5bb..fb945c619e 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -519,7 +519,8 @@ type Checkout implements Node {shippingAddress: AddressshippingMethod: ShippingMethodnote: String!- discountAmount: Money+ discountAmount: Money @deprecated(reason: "Use discount instead.")+ discount: MoneydiscountName: StringtranslatedDiscountName: StringvoucherCode: String@@ -2014,12 +2015,12 @@ type Order implements Node {billingAddress: AddressshippingAddress: AddressshippingMethod: ShippingMethod- shippingPrice: TaxedMoneyshippingMethodName: String+ shippingPrice: TaxedMoneytoken: String!voucher: VouchergiftCards: [GiftCard]- discountAmount: Money+ discount: MoneydiscountName: String!translatedDiscountName: String!displayGrossPrices: Boolean!@@ -2044,6 +2045,7 @@ type Order implements Node {totalBalance: Money!userEmail: StringisShippingRequired: Boolean!+ discountAmount: Money!}enum OrderAction {@@ -2877,7 +2879,9 @@ type ProductVariantCreate {input ProductVariantCreateInput {attributes: [AttributeValueInput]!costPrice: Decimal+ costPriceAmount: DecimalpriceOverride: Decimal+ priceOverrideAmount: Decimalsku: Stringquantity: InttrackInventory: Boolean@@ -2893,7 +2897,9 @@ type ProductVariantDelete {input ProductVariantInput {attributes: [AttributeValueInput]costPrice: Decimal+ costPriceAmount: DecimalpriceOverride: Decimal+ priceOverrideAmount: Decimalsku: Stringquantity: InttrackInventory: Boolean@@ -3154,8 +3160,11 @@ type ShippingPriceDelete {input ShippingPriceInput {name: Stringprice: Decimal+ priceAmount: DecimalminimumOrderPrice: Decimal+ minimumOrderPriceAmount: DecimalmaximumOrderPrice: Decimal+ maximumOrderPriceAmount: DecimalminimumOrderWeight: WeightScalarmaximumOrderWeight: WeightScalartype: ShippingMethodTypeEnum@@ -3605,13 +3614,14 @@ type Voucher implements Node {applyOncePerCustomer: Boolean!discountValueType: DiscountValueTypeEnum!discountValue: Float!- minAmountSpent: Money+ minSpent: MoneyminCheckoutItemsQuantity: Intcategories(before: String, after: String, first: Int, last: Int): CategoryCountableConnectioncollections(before: String, after: String, first: Int, last: Int): CollectionCountableConnectionproducts(before: String, after: String, first: Int, last: Int): ProductCountableConnectioncountries: [CountryDisplay]translation(languageCode: LanguageCodeEnum!): VoucherTranslation+ minAmountSpent: Money @deprecated(reason: "Use the minAmount field instead.")}type VoucherAddCatalogues {@@ -3671,6 +3681,7 @@ input VoucherInput {collections: [ID]categories: [ID]minAmountSpent: Decimal+ minSpentAmount: DecimalminCheckoutItemsQuantity: Intcountries: [String]applyOncePerOrder: Booleandiff --git a/saleor/graphql/shipping/mutations.py b/saleor/graphql/shipping/mutations.pyindex 1f9eeca8c2..1956bc1b39 100644--- a/saleor/graphql/shipping/mutations.py+++ b/saleor/graphql/shipping/mutations.py@@ -11,11 +11,29 @@ from .types import ShippingMethod, ShippingZoneclass ShippingPriceInput(graphene.InputObjectType):name = graphene.String(description="Name of the shipping method.")- price = Decimal(description="Shipping price of the shipping method.")+ price = Decimal(+ description=(+ "Deprecated: use priceAmount instead.\n"+ "Shipping price of the shipping method."+ )+ )+ price_amount = Decimal(description="Shipping price of the shipping method.")minimum_order_price = Decimal(+ description=(+ "deprecated: use minimumOrderPriceAmount instead.\n"+ "Minimum order price to use this shipping method"+ )+ )+ minimum_order_price_amount = Decimal(description="Minimum order price to use this shipping method")maximum_order_price = Decimal(+ description=(+ "deprecated: use maximumOrderPriceAmount instead.\n"+ "Maximum order price to use this shipping method"+ )+ )+ maximum_order_price_amount = Decimal(description="Maximum order price to use this shipping method")minimum_order_weight = WeightScalar(@@ -103,12 +121,28 @@ class ShippingZoneDelete(ModelDeleteMutation):class ShippingPriceMixin:@classmethoddef clean_input(cls, info, instance, data):+ price_amount = data.pop("price", None)+ if price_amount is not None:+ data["price_amount"] = price_amount+cleaned_input = super().clean_input(info, instance, data)+cleaned_type = cleaned_input.get("type")if cleaned_type:if cleaned_type == ShippingMethodTypeEnum.PRICE.value:- min_price = cleaned_input.get("minimum_order_price")- max_price = cleaned_input.get("maximum_order_price")+ min_price = cleaned_input.pop("minimum_order_price", None)+ max_price = cleaned_input.pop("maximum_order_price", None)++ if min_price is not None:+ cleaned_input["minimum_order_price_amount"] = min_price+ else:+ min_price = cleaned_input.get("minimum_order_price_amount")++ if max_price is not None:+ cleaned_input["maximum_order_price_amount"] = max_price+ else:+ max_price = cleaned_input.get("maximum_order_price_amount")+if (min_price is not Noneand max_price is not Nonediff --git a/saleor/order/migrations/0001_initial.py b/saleor/order/migrations/0001_initial.pyindex d05ce999aa..10150b0a24 100644--- a/saleor/order/migrations/0001_initial.py+++ b/saleor/order/migrations/0001_initial.py@@ -4,7 +4,6 @@ from __future__ import unicode_literalsimport django.core.validatorsimport django.db.models.deletionimport django.utils.timezone-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -49,11 +48,10 @@ class Migration(migrations.Migration):),("shipping_price",- django_prices.models.MoneyField(+ models.DecimalField(decimal_places=4,default=0,editable=False,- currency=b"USD",max_digits=12,verbose_name="shipping price",),diff --git a/saleor/order/migrations/0003_auto_20150825_1433.py b/saleor/order/migrations/0003_auto_20150825_1433.pyindex 646e0853ea..eb88f6f754 100644--- a/saleor/order/migrations/0003_auto_20150825_1433.py+++ b/saleor/order/migrations/0003_auto_20150825_1433.py@@ -1,8 +1,6 @@# -*- coding: utf-8 -*-from __future__ import unicode_literals-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -14,11 +12,10 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="deliverygroup",name="shipping_price",- field=django_prices.models.MoneyField(+ field=models.DecimalField(verbose_name="shipping price",decimal_places=4,default=0,- currency=settings.DEFAULT_CURRENCY,max_digits=12,editable=False,),diff --git a/saleor/order/migrations/0004_order_total.py b/saleor/order/migrations/0004_order_total.pyindex ece5bde776..658aeb1e82 100644--- a/saleor/order/migrations/0004_order_total.py+++ b/saleor/order/migrations/0004_order_total.py@@ -1,9 +1,7 @@# -*- coding: utf-8 -*-from __future__ import unicode_literals-import django_prices.models-from django.conf import settings-from django.db import migrations+from django.db import migrations, modelsclass Migration(migrations.Migration):@@ -14,9 +12,8 @@ class Migration(migrations.Migration):migrations.AddField(model_name="order",name="total",- field=django_prices.models.MoneyField(+ field=models.DecimalField(decimal_places=2,- currency=settings.DEFAULT_CURRENCY,max_digits=12,blank=True,null=True,diff --git a/saleor/order/migrations/0009_auto_20151201_0820.py b/saleor/order/migrations/0009_auto_20151201_0820.pyindex e38b543f6d..f0e32cbdec 100644--- a/saleor/order/migrations/0009_auto_20151201_0820.py+++ b/saleor/order/migrations/0009_auto_20151201_0820.py@@ -1,8 +1,6 @@# -*- coding: utf-8 -*-from __future__ import unicode_literals-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -17,9 +15,8 @@ class Migration(migrations.Migration):migrations.AddField(model_name="order",name="total_tax",- field=django_prices.models.MoneyField(+ field=models.DecimalField(decimal_places=2,- currency=settings.DEFAULT_CURRENCY,max_digits=12,blank=True,null=True,diff --git a/saleor/order/migrations/0011_auto_20160207_0534.py b/saleor/order/migrations/0011_auto_20160207_0534.pyindex f3def9a868..7bf65eacdd 100644--- a/saleor/order/migrations/0011_auto_20160207_0534.py+++ b/saleor/order/migrations/0011_auto_20160207_0534.py@@ -3,8 +3,6 @@from __future__ import unicode_literalsimport django.db.models.deletion-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -19,12 +17,8 @@ class Migration(migrations.Migration):migrations.AddField(model_name="order",name="discount_amount",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AddField(diff --git a/saleor/order/migrations/0013_auto_20160906_0741.py b/saleor/order/migrations/0013_auto_20160906_0741.pyindex 6fb5efcf55..0fef233470 100644--- a/saleor/order/migrations/0013_auto_20160906_0741.py+++ b/saleor/order/migrations/0013_auto_20160906_0741.py@@ -2,8 +2,6 @@# Generated by Django 1.10.1 on 2016-09-06 12:41from __future__ import unicode_literals-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -47,9 +45,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="total_net",- field=django_prices.models.MoneyField(+ field=models.DecimalField(blank=True,- currency=settings.DEFAULT_CURRENCY,decimal_places=2,max_digits=12,null=True,@@ -59,9 +56,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="total_tax",- field=django_prices.models.MoneyField(+ field=models.DecimalField(blank=True,- currency=settings.DEFAULT_CURRENCY,decimal_places=2,max_digits=12,null=True,diff --git a/saleor/order/migrations/0015_auto_20170206_0407.py b/saleor/order/migrations/0015_auto_20170206_0407.pyindex ef35eaddba..43b878ffbd 100644--- a/saleor/order/migrations/0015_auto_20170206_0407.py+++ b/saleor/order/migrations/0015_auto_20170206_0407.py@@ -3,7 +3,6 @@from __future__ import unicode_literalsimport django.db.models.deletion-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -98,9 +97,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="discount_amount",- field=django_prices.models.MoneyField(+ field=models.DecimalField(blank=True,- currency=settings.DEFAULT_CURRENCY,decimal_places=2,max_digits=12,null=True,@@ -129,9 +127,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="total_net",- field=django_prices.models.MoneyField(+ field=models.DecimalField(blank=True,- currency=settings.DEFAULT_CURRENCY,decimal_places=2,max_digits=12,null=True,@@ -141,9 +138,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="total_tax",- field=django_prices.models.MoneyField(+ field=models.DecimalField(blank=True,- currency=settings.DEFAULT_CURRENCY,decimal_places=2,max_digits=12,null=True,diff --git a/saleor/order/migrations/0026_auto_20171218_0428.py b/saleor/order/migrations/0026_auto_20171218_0428.pyindex ae97d37874..73d98fb2e0 100644--- a/saleor/order/migrations/0026_auto_20171218_0428.py+++ b/saleor/order/migrations/0026_auto_20171218_0428.py@@ -2,8 +2,6 @@# Generated by Django 1.11.5 on 2017-12-18 10:28from __future__ import unicode_literals-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -17,8 +15,7 @@ class Migration(migrations.Migration):migrations.AddField(model_name="order",name="shipping_price",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,+ field=models.DecimalField(decimal_places=4,default=0,editable=False,diff --git a/saleor/order/migrations/0027_auto_20180108_0814.py b/saleor/order/migrations/0027_auto_20180108_0814.pyindex 9841f08b10..e42f21498c 100644--- a/saleor/order/migrations/0027_auto_20180108_0814.py+++ b/saleor/order/migrations/0027_auto_20180108_0814.py@@ -5,7 +5,6 @@ from __future__ import unicode_literalsimport django.core.validatorsimport django.db.models.deletionimport django.utils.timezone-import django_prices.modelsfrom django.conf import settingsfrom django.db import migrations, models@@ -65,12 +64,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="discount_amount",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AlterField(@@ -99,12 +94,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="shipping_price",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=4,- default=0,- editable=False,- max_digits=12,+ field=models.DecimalField(+ decimal_places=4, default=0, editable=False, max_digits=12),),migrations.AlterField(@@ -115,23 +106,15 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="total_net",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AlterField(model_name="order",name="total_tax",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AlterField(diff --git a/saleor/order/migrations/0034_auto_20180221_1056.py b/saleor/order/migrations/0034_auto_20180221_1056.pyindex 7e5f4264b9..084edc53ea 100644--- a/saleor/order/migrations/0034_auto_20180221_1056.py+++ b/saleor/order/migrations/0034_auto_20180221_1056.py@@ -1,8 +1,6 @@# Generated by Django 2.0.2 on 2018-02-21 16:56-import django_prices.models-from django.conf import settings-from django.db import migrations+from django.db import migrations, modelsclass Migration(migrations.Migration):@@ -13,26 +11,18 @@ class Migration(migrations.Migration):migrations.AddField(model_name="order",name="total_gross",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AlterField(model_name="orderline",name="unit_price_gross",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY, decimal_places=4, max_digits=12- ),+ field=models.DecimalField(decimal_places=4, max_digits=12),),migrations.AlterField(model_name="orderline",name="unit_price_net",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY, decimal_places=4, max_digits=12- ),+ field=models.DecimalField(decimal_places=4, max_digits=12),),]diff --git a/saleor/order/migrations/0037_auto_20180228_0450.py b/saleor/order/migrations/0037_auto_20180228_0450.pyindex f9aa0273a9..3020ceeb13 100644--- a/saleor/order/migrations/0037_auto_20180228_0450.py+++ b/saleor/order/migrations/0037_auto_20180228_0450.py@@ -1,8 +1,6 @@# Generated by Django 2.0.2 on 2018-02-28 10:50-import django_prices.models-from django.conf import settings-from django.db import migrations+from django.db import migrations, modelsclass Migration(migrations.Migration):@@ -18,23 +16,15 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="shipping_price_gross",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- editable=False,- max_digits=12,+ field=models.DecimalField(+ decimal_places=2, default=0, editable=False, max_digits=12),),migrations.AddField(model_name="order",name="shipping_price_net",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- editable=False,- max_digits=12,+ field=models.DecimalField(+ decimal_places=2, default=0, editable=False, max_digits=12),),]diff --git a/saleor/order/migrations/0039_auto_20180312_1203.py b/saleor/order/migrations/0039_auto_20180312_1203.pyindex 1c13c4416d..87710578bf 100644--- a/saleor/order/migrations/0039_auto_20180312_1203.py+++ b/saleor/order/migrations/0039_auto_20180312_1203.py@@ -1,8 +1,6 @@# Generated by Django 2.0.2 on 2018-03-12 17:03-import django_prices.models-from django.conf import settings-from django.db import migrations+from django.db import migrations, modelsclass Migration(migrations.Migration):@@ -13,21 +11,11 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="total_gross",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.AlterField(model_name="order",name="total_net",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),]diff --git a/saleor/order/migrations/0044_auto_20180326_1055.py b/saleor/order/migrations/0044_auto_20180326_1055.pyindex 89eebaa435..19696032bb 100644--- a/saleor/order/migrations/0044_auto_20180326_1055.py+++ b/saleor/order/migrations/0044_auto_20180326_1055.py@@ -1,8 +1,6 @@# Generated by Django 2.0.3 on 2018-03-26 15:55import django.db.models.deletion-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -39,12 +37,7 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="discount_amount",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.AlterField(model_name="order",diff --git a/saleor/order/migrations/0045_auto_20180329_0142.py b/saleor/order/migrations/0045_auto_20180329_0142.pyindex 22f9e6f292..a341b4d1ec 100644--- a/saleor/order/migrations/0045_auto_20180329_0142.py+++ b/saleor/order/migrations/0045_auto_20180329_0142.py@@ -1,8 +1,6 @@# Generated by Django 2.0.3 on 2018-03-29 06:42import django.db.models.deletion-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -31,15 +29,11 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="orderline",name="unit_price_gross",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY, decimal_places=2, max_digits=12- ),+ field=models.DecimalField(decimal_places=2, max_digits=12),),migrations.AlterField(model_name="orderline",name="unit_price_net",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY, decimal_places=2, max_digits=12- ),+ field=models.DecimalField(decimal_places=2, max_digits=12),),]diff --git a/saleor/order/migrations/0065_auto_20181017_1346.py b/saleor/order/migrations/0065_auto_20181017_1346.pyindex 511316384b..dc7b6aada3 100644--- a/saleor/order/migrations/0065_auto_20181017_1346.py+++ b/saleor/order/migrations/0065_auto_20181017_1346.py@@ -2,12 +2,8 @@from decimal import Decimal-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models-import saleor.core-class Migration(migrations.Migration):@@ -20,32 +16,17 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="order",name="discount_amount",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=saleor.core.taxes.zero_money,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.AlterField(model_name="order",name="total_gross",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=saleor.core.taxes.zero_money,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.AlterField(model_name="order",name="total_net",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=saleor.core.taxes.zero_money,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.RemoveField(model_name="payment", name="order"),migrations.DeleteModel(name="Payment"),diff --git a/saleor/order/migrations/0072_django_price_2.py b/saleor/order/migrations/0072_django_price_2.pynew file mode 100644index 0000000000..59e3ffe341--- /dev/null+++ b/saleor/order/migrations/0072_django_price_2.py@@ -0,0 +1,48 @@+# Generated by Django 2.2.4 on 2019-08-14 09:13++from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [("order", "0071_order_gift_cards")]++ operations = [+ migrations.RenameField(+ model_name="order",+ old_name="shipping_price_gross",+ new_name="shipping_price_gross_amount",+ ),+ migrations.RenameField(+ model_name="order",+ old_name="shipping_price_net",+ new_name="shipping_price_net_amount",+ ),+ migrations.RenameField(+ model_name="order", old_name="total_gross", new_name="total_gross_amount"+ ),+ migrations.RenameField(+ model_name="order", old_name="total_net", new_name="total_net_amount"+ ),+ migrations.RenameField(+ model_name="orderline",+ old_name="unit_price_gross",+ new_name="unit_price_gross_amount",+ ),+ migrations.RenameField(+ model_name="orderline",+ old_name="unit_price_net",+ new_name="unit_price_net_amount",+ ),+ migrations.AddField(+ model_name="order",+ name="currency",+ field=models.CharField(default=settings.DEFAULT_CURRENCY, max_length=3),+ ),+ migrations.AddField(+ model_name="orderline",+ name="currency",+ field=models.CharField(default=settings.DEFAULT_CURRENCY, max_length=3),+ ),+ ]diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 55acce7208..41571acfe0 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -44,7 +44,7 @@ class OrderQueryset(models.QuerySet):statuses = {OrderStatus.UNFULFILLED, OrderStatus.PARTIALLY_FULFILLED}qs = self.filter(status__in=statuses, payments__is_active=True)qs = qs.annotate(amount_paid=Sum("payments__captured_amount"))- return qs.filter(total_gross__lte=F("amount_paid"))+ return qs.filter(total_gross_amount__lte=F("amount_paid"))def ready_to_capture(self):"""Return orders with payments to capture.@@ -81,6 +81,9 @@ class Order(models.Model):Address, related_name="+", editable=False, null=True, on_delete=models.SET_NULL)user_email = models.EmailField(blank=True, default="")++ currency = models.CharField(max_length=3, default=settings.DEFAULT_CURRENCY)+shipping_method = models.ForeignKey(ShippingMethod,blank=True,@@ -88,52 +91,72 @@ class Order(models.Model):related_name="orders",on_delete=models.SET_NULL,)- shipping_price_net = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ shipping_method_name = models.CharField(+ max_length=255, null=True, default=None, blank=True, editable=False+ )++ shipping_price_net_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=0,editable=False,)- shipping_price_gross = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ shipping_price_net = MoneyField(+ amount_field="shipping_price_net_amount", currency_field="currency"+ )++ shipping_price_gross_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=0,editable=False,)- shipping_price = TaxedMoneyField(- net_field="shipping_price_net", gross_field="shipping_price_gross"+ shipping_price_gross = MoneyField(+ amount_field="shipping_price_gross_amount", currency_field="currency")- shipping_method_name = models.CharField(- max_length=255, null=True, default=None, blank=True, editable=False++ shipping_price = TaxedMoneyField(+ net_amount_field="shipping_price_net_amount",+ gross_amount_field="shipping_price_gross_amount",+ currency_field="currency",)+token = models.CharField(max_length=36, unique=True, blank=True)# Token of a checkout instance that this order was created fromcheckout_token = models.CharField(max_length=36, blank=True)- total_net = MoneyField(- currency=settings.DEFAULT_CURRENCY,++ total_net_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- default=zero_money,+ default=0,)- total_gross = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ total_net = MoneyField(amount_field="total_net_amount", currency_field="currency")++ total_gross_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- default=zero_money,+ default=0,+ )+ total_gross = MoneyField(+ amount_field="total_gross_amount", currency_field="currency")- total = TaxedMoneyField(net_field="total_net", gross_field="total_gross")++ total = TaxedMoneyField(+ net_amount_field="total_net_amount",+ gross_amount_field="total_gross_amount",+ currency_field="currency",+ )+voucher = models.ForeignKey(Voucher, blank=True, null=True, related_name="+", on_delete=models.SET_NULL)gift_cards = models.ManyToManyField(GiftCard, blank=True, related_name="orders")- discount_amount = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ discount_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,- default=zero_money,+ default=0,)+ discount = MoneyField(amount_field="discount_amount", currency_field="currency")discount_name = models.CharField(max_length=255, default="", blank=True)translated_discount_name = models.CharField(max_length=255, default="", blank=True)display_gross_prices = models.BooleanField(default=True)@@ -341,19 +364,31 @@ class OrderLine(models.Model):quantity_fulfilled = models.IntegerField(validators=[MinValueValidator(0)], default=0)- unit_price_net = MoneyField(- currency=settings.DEFAULT_CURRENCY,++ currency = models.CharField(max_length=3, default=settings.DEFAULT_CURRENCY)++ unit_price_net_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,)- unit_price_gross = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ unit_price_net = MoneyField(+ amount_field="unit_price_net_amount", currency_field="currency"+ )++ unit_price_gross_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,)+ unit_price_gross = MoneyField(+ amount_field="unit_price_gross_amount", currency_field="currency"+ )+unit_price = TaxedMoneyField(- net_field="unit_price_net", gross_field="unit_price_gross"+ net_amount_field="unit_price_net_amount",+ gross_amount_field="unit_price_gross_amount",+ currency="currency",)+tax_rate = models.DecimalField(max_digits=5, decimal_places=2, default=Decimal("0.0"))diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex 186d2090be..6239201dab 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -111,17 +111,17 @@ def update_voucher_discount(func):if kwargs.pop("update_voucher_discount", True):order = args[0]try:- discount_amount = get_voucher_discount_for_order(order)+ discount = get_voucher_discount_for_order(order)except NotApplicable:- discount_amount = zero_money()- order.discount_amount = discount_amount+ discount = zero_money()+ order.discount = discountreturn func(*args, **kwargs)return decorator@update_voucher_discount-def recalculate_order(order, **kwargs):+def recalculate_order(order: Order, **kwargs):"""Recalculate and assign total price of order.Total price is a sum of items in order and order shipping price minus@@ -135,9 +135,9 @@ def recalculate_order(order, **kwargs):prices = [line.get_total() for line in lines]total = sum(prices, order.shipping_price)# discount amount can't be greater than order total- order.discount_amount = min(order.discount_amount, total.gross)- if order.discount_amount:- total -= order.discount_amount+ order.discount_amount = min(order.discount_amount, total.gross.amount)+ if order.discount:+ total -= order.discountorder.total = totalorder.save()recalculate_order_weight(order)@@ -157,11 +157,17 @@ def update_order_prices(order, discounts):"""Update prices in order with given discounts and proper taxes."""manager = get_extensions_manager()for line in order:- if line.variant:+ if line.variant: # type: OrderLineunit_price = line.variant.get_price(discounts)- line.unit_price_net = unit_price- line.unit_price_gross = unit_price- line.save(update_fields=["unit_price_net", "unit_price_gross"])+ unit_price = TaxedMoney(unit_price, unit_price)+ line.unit_price = unit_price+ line.save(+ update_fields=[+ "currency",+ "unit_price_net_amount",+ "unit_price_gross_amount",+ ]+ )price = manager.calculate_order_line_unit(line)if price != line.unit_price:@@ -282,6 +288,7 @@ def add_variant_to_order(line.save(update_fields=["quantity"])except OrderLine.DoesNotExist:unit_price = variant.get_price(discounts)+ unit_price = TaxedMoney(net=unit_price, gross=unit_price)product_name = variant.display_product()translated_product_name = variant.display_product(translated=True)if translated_product_name == product_name:@@ -292,16 +299,21 @@ def add_variant_to_order(product_sku=variant.sku,is_shipping_required=variant.is_shipping_required(),quantity=quantity,- unit_price_net=unit_price,- unit_price_gross=unit_price,+ unit_price=unit_price,variant=variant,)manager = get_extensions_manager()unit_price = manager.calculate_order_line_unit(line)- line.unit_price_net = unit_price.net- line.unit_price_gross = unit_price.gross+ line.unit_price = unit_priceline.tax_rate = unit_price.tax / unit_price.net- line.save(update_fields=["unit_price_net", "unit_price_gross", "tax_rate"])+ line.save(+ update_fields=[+ "currency",+ "unit_price_net_amount",+ "unit_price_gross_amount",+ "tax_rate",+ ]+ )if variant.track_inventory and track_inventory:allocate_stock(variant, quantity)@@ -320,9 +332,9 @@ def add_gift_card_to_order(order, gift_card, total_price_left):total_price_left = zero_money(total_price_left.currency)else:total_price_left = total_price_left - gift_card.current_balance- gift_card.current_balance = 0+ gift_card.current_balance_amount = 0gift_card.last_used_on = timezone.now()- gift_card.save(update_fields=["current_balance", "last_used_on"])+ gift_card.save(update_fields=["current_balance_amount", "last_used_on"])return total_price_leftdiff --git a/saleor/product/filters.py b/saleor/product/filters.pyindex 970d0b0cb5..6280343113 100644--- a/saleor/product/filters.py+++ b/saleor/product/filters.py@@ -13,7 +13,7 @@ SORT_BY_FIELDS = OrderedDict([("name", pgettext_lazy("Product list sorting option", "name")),(- "minimal_variant_price",+ "minimal_variant_price_amount",pgettext_lazy("Product list sorting option", "price"),),("updated_at", pgettext_lazy("Product list sorting option", "last updated")),@@ -36,7 +36,10 @@ class ProductFilter(SortedFilterSet):fields=SORT_BY_FIELDS.keys(),field_labels=SORT_BY_FIELDS,)- minimal_variant_price = RangeFilter(label=pgettext_lazy("Currency amount", "Price"))+ minimal_variant_price = RangeFilter(+ label=pgettext_lazy("Currency amount", "Price"),+ field_name="minimal_variant_price_amount",+ )class Meta:model = Productdiff --git a/saleor/product/forms.py b/saleor/product/forms.pyindex c4932cc576..84800bc24f 100644--- a/saleor/product/forms.py+++ b/saleor/product/forms.py@@ -3,7 +3,7 @@ import jsonfrom django import formsfrom django.utils.encoding import smart_textfrom django.utils.translation import pgettext_lazy-from django_prices.templatetags.prices_i18n import amount+from django_prices.templatetags.prices import amountfrom draftjs_sanitizer import SafeJSONEncoderfrom ..checkout.forms import AddToCheckoutFormdiff --git a/saleor/product/migrations/0001_initial.py b/saleor/product/migrations/0001_initial.pyindex a57e837e62..7012845b64 100644--- a/saleor/product/migrations/0001_initial.py+++ b/saleor/product/migrations/0001_initial.py@@ -4,9 +4,7 @@ from __future__ import unicode_literalsfrom decimal import Decimalimport django.core.validators-import django_prices.modelsimport versatileimagefield.fields-from django.conf import settingsfrom django.db import migrations, models@@ -107,11 +105,8 @@ class Migration(migrations.Migration):("name", models.CharField(max_length=255)),("discount",- django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- verbose_name="discount value",- max_digits=12,- decimal_places=2,+ models.DecimalField(+ verbose_name="discount value", max_digits=12, decimal_places=2),),],@@ -132,11 +127,8 @@ class Migration(migrations.Migration):("description", models.TextField(verbose_name="description")),("price",- django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- verbose_name="price",- max_digits=12,- decimal_places=2,+ models.DecimalField(+ verbose_name="price", max_digits=12, decimal_places=2),),(@@ -239,9 +231,8 @@ class Migration(migrations.Migration):),("price_override",- django_prices.models.MoneyField(+ models.DecimalField(decimal_places=2,- currency=settings.DEFAULT_CURRENCY,max_digits=12,blank=True,null=True,@@ -295,9 +286,8 @@ class Migration(migrations.Migration):),("cost_price",- django_prices.models.MoneyField(+ models.DecimalField(decimal_places=2,- currency=settings.DEFAULT_CURRENCY,max_digits=12,blank=True,null=True,diff --git a/saleor/product/migrations/0005_auto_20150825_1433.py b/saleor/product/migrations/0005_auto_20150825_1433.pyindex fd6a6f53e8..f8bdd6bfbd 100644--- a/saleor/product/migrations/0005_auto_20150825_1433.py+++ b/saleor/product/migrations/0005_auto_20150825_1433.py@@ -1,8 +1,6 @@# -*- coding: utf-8 -*-from __future__ import unicode_literals-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -14,21 +12,15 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="fixedproductdiscount",name="discount",- field=django_prices.models.MoneyField(- verbose_name="discount value",- max_digits=12,- decimal_places=2,- currency=settings.DEFAULT_CURRENCY,+ field=models.DecimalField(+ verbose_name="discount value", max_digits=12, decimal_places=2),),migrations.AlterField(model_name="product",name="price",- field=django_prices.models.MoneyField(- verbose_name="price",- max_digits=12,- decimal_places=2,- currency=settings.DEFAULT_CURRENCY,+ field=models.DecimalField(+ verbose_name="price", max_digits=12, decimal_places=2),),migrations.AlterField(@@ -41,11 +33,10 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="productvariant",name="price_override",- field=django_prices.models.MoneyField(+ field=models.DecimalField(verbose_name="price override",decimal_places=2,blank=True,- currency=settings.DEFAULT_CURRENCY,max_digits=12,null=True,),@@ -64,11 +55,10 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="stock",name="cost_price",- field=django_prices.models.MoneyField(+ field=models.DecimalField(verbose_name="cost price",decimal_places=2,blank=True,- currency=settings.DEFAULT_CURRENCY,max_digits=12,null=True,),diff --git a/saleor/product/migrations/0044_auto_20180108_0814.py b/saleor/product/migrations/0044_auto_20180108_0814.pyindex 4110e44d08..cb68af0559 100644--- a/saleor/product/migrations/0044_auto_20180108_0814.py+++ b/saleor/product/migrations/0044_auto_20180108_0814.py@@ -7,9 +7,7 @@ from decimal import Decimalimport django.contrib.postgres.fields.hstoreimport django.core.validatorsimport django.db.models.deletion-import django_prices.modelsimport versatileimagefield.fields-from django.conf import settingsfrom django.db import migrations, models@@ -99,9 +97,7 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="product",name="price",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY, decimal_places=2, max_digits=12- ),+ field=models.DecimalField(decimal_places=2, max_digits=12),),migrations.AlterField(model_name="product",@@ -209,12 +205,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="productvariant",name="price_override",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AlterField(@@ -225,12 +217,8 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="stock",name="cost_price",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AlterField(diff --git a/saleor/product/migrations/0058_auto_20180329_0142.py b/saleor/product/migrations/0058_auto_20180329_0142.pyindex af7560b662..749341fe5b 100644--- a/saleor/product/migrations/0058_auto_20180329_0142.py+++ b/saleor/product/migrations/0058_auto_20180329_0142.py@@ -3,8 +3,6 @@from decimal import Decimalimport django.core.validators-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -22,12 +20,8 @@ class Migration(migrations.Migration):migrations.AddField(model_name="productvariant",name="cost_price",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AddField(diff --git a/saleor/product/migrations/0105_product_minimal_variant_price.py b/saleor/product/migrations/0105_product_minimal_variant_price.pyindex e2ed61efcd..7f9745ab94 100644--- a/saleor/product/migrations/0105_product_minimal_variant_price.py+++ b/saleor/product/migrations/0105_product_minimal_variant_price.py@@ -1,8 +1,6 @@# Generated by Django 2.2.1 on 2019-06-10 11:23-import django_prices.models-from django.conf import settings-from django.db import migrations+from django.db import migrations, modelsdef populate_product_minimal_variant_price(apps, schema_editor):@@ -13,8 +11,8 @@ def populate_product_minimal_variant_price(apps, schema_editor):# depends on models' methods and we would have to copy all the code into# this migration. Instead we should manually run the management command:# - "update_all_products_minimal_variant_prices"- product.minimal_variant_price = product.price- product.save(update_fields=["minimal_variant_price"])+ product.minimal_variant_price_amount = product.price_amount+ product.save(update_fields=["minimal_variant_price_amount"])class Migration(migrations.Migration):@@ -24,13 +22,8 @@ class Migration(migrations.Migration):operations = [migrations.AddField(model_name="product",- name="minimal_variant_price",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,- ),+ name="minimal_variant_price_amount",+ field=models.DecimalField(decimal_places=2, max_digits=12, null=True),),migrations.RunPython(populate_product_minimal_variant_price,@@ -38,9 +31,7 @@ class Migration(migrations.Migration):),migrations.AlterField(model_name="product",- name="minimal_variant_price",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY, decimal_places=2, max_digits=12- ),+ name="minimal_variant_price_amount",+ field=models.DecimalField(decimal_places=2, max_digits=12),),]diff --git a/saleor/product/migrations/0106_django_prices_2.py b/saleor/product/migrations/0106_django_prices_2.pynew file mode 100644index 0000000000..0b4c652a05--- /dev/null+++ b/saleor/product/migrations/0106_django_prices_2.py@@ -0,0 +1,37 @@+# Generated by Django 2.2.4 on 2019-08-14 09:13++from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [("product", "0105_product_minimal_variant_price")]++ operations = [+ migrations.RenameField(+ model_name="product", old_name="price", new_name="price_amount"+ ),+ migrations.RenameField(+ model_name="productvariant",+ old_name="cost_price",+ new_name="cost_price_amount",+ ),+ migrations.RenameField(+ model_name="productvariant",+ old_name="price_override",+ new_name="price_override_amount",+ ),+ migrations.AddField(+ model_name="product",+ name="currency",+ field=models.CharField(default=settings.DEFAULT_CURRENCY, max_length=10),+ ),+ migrations.AddField(+ model_name="productvariant",+ name="currency",+ field=models.CharField(+ blank=True, default=settings.DEFAULT_CURRENCY, max_length=10, null=True+ ),+ ),+ ]diff --git a/saleor/product/models.py b/saleor/product/models.pyindex 3af113c8cb..309426d63f 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -15,7 +15,7 @@ from django.utils.text import slugifyfrom django.utils.translation import pgettext_lazyfrom django_measurement.models import MeasurementFieldfrom django_prices.models import MoneyField-from django_prices.templatetags import prices_i18n+from django_prices.templatetags import pricesfrom draftjs_sanitizer import clean_draft_jsfrom measurement.measures import Weightfrom mptt.managers import TreeManager@@ -141,13 +141,20 @@ class ProductType(ModelWithMetadata):class ProductsQueryset(PublishedQuerySet):+ MINIMAL_PRICE_FIELDS = {"minimal_variant_price_amount", "minimal_variant_price"}+def create(self, **kwargs):"""Create a product.In the case of absent "minimal_variant_price" make it default to the "price""""- if "minimal_variant_price" not in kwargs:- kwargs["minimal_variant_price"] = kwargs.get("price")+ if not kwargs.keys() & self.MINIMAL_PRICE_FIELDS:+ minimal_amount = None+ if "price" in kwargs:+ minimal_amount = kwargs["price"].amount+ elif "price_amount" in kwargs:+ minimal_amount = kwargs["price_amount"]+ kwargs["minimal_variant_price_amount"] = minimal_amountreturn super().create(**kwargs)def bulk_create(self, objs, batch_size=None, ignore_conflicts=False):@@ -157,8 +164,8 @@ class ProductsQueryset(PublishedQuerySet):make it default to the "price"."""for obj in objs:- if obj.minimal_variant_price is None:- obj.minimal_variant_price = obj.price+ if obj.minimal_variant_price_amount is None:+ obj.minimal_variant_price_amount = obj.price.amountreturn super().bulk_create(objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts)@@ -186,16 +193,22 @@ class Product(SeoModel, ModelWithMetadata, PublishableModel):category = models.ForeignKey(Category, related_name="products", on_delete=models.CASCADE)- price = MoneyField(- currency=settings.DEFAULT_CURRENCY,++ currency = models.CharField(max_length=10, default=settings.DEFAULT_CURRENCY)++ price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,)- minimal_variant_price = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ price = MoneyField(amount_field="price_amount", currency_field="currency")++ minimal_variant_price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,)+ minimal_variant_price = MoneyField(+ amount_field="minimal_variant_price_amount", currency_field="currency"+ )attributes = FilterableJSONBField(default=dict, blank=True, validators=[validate_attribute_json])@@ -237,9 +250,9 @@ class Product(SeoModel, ModelWithMetadata, PublishableModel):def save(self, force_insert=False, force_update=False, using=None, update_fields=None):- # Make sure the "minimal_variant_price" is set- if self.minimal_variant_price is None:- self.minimal_variant_price = self.price+ # Make sure the "minimal_variant_price_amount" is set+ if self.minimal_variant_price_amount is None:+ self.minimal_variant_price_amount = self.price_amountreturn super().save(force_insert, force_update, using, update_fields)@property@@ -339,13 +352,18 @@ class ProductVariantQueryset(models.QuerySet):class ProductVariant(ModelWithMetadata):sku = models.CharField(max_length=32, unique=True)name = models.CharField(max_length=255, blank=True)- price_override = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ currency = models.CharField(+ max_length=10, default=settings.DEFAULT_CURRENCY, blank=True, null=True+ )+ price_override_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,blank=True,null=True,)+ price_override = MoneyField(+ amount_field="price_override_amount", currency_field="currency"+ )product = models.ForeignKey(Product, related_name="variants", on_delete=models.CASCADE)@@ -360,13 +378,13 @@ class ProductVariant(ModelWithMetadata):quantity_allocated = models.IntegerField(validators=[MinValueValidator(0)], default=Decimal(0))- cost_price = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ cost_price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,blank=True,null=True,)+ cost_price = MoneyField(amount_field="cost_price_amount", currency_field="currency")weight = MeasurementField(measurement=Weight, unit_choices=WeightUnits.CHOICES, blank=True, null=True)@@ -449,11 +467,7 @@ class ProductVariant(ModelWithMetadata):def get_ajax_label(self, discounts=None):price = self.get_price(discounts)- return "%s, %s, %s" % (- self.sku,- self.display_product(),- prices_i18n.amount(price),- )+ return "%s, %s, %s" % (self.sku, self.display_product(), prices.amount(price))class ProductVariantTranslation(models.Model):diff --git a/saleor/product/utils/variant_prices.py b/saleor/product/utils/variant_prices.pyindex cb420d3f70..b923f2925e 100644--- a/saleor/product/utils/variant_prices.py+++ b/saleor/product/utils/variant_prices.py@@ -2,12 +2,13 @@ import operatorfrom functools import reducefrom django.db.models.query_utils import Q+from prices import Moneyfrom ...discount.utils import fetch_active_discountsfrom ..models import Product-def _get_product_minimal_variant_price(product, discounts):+def _get_product_minimal_variant_price(product, discounts) -> Money:# Start with the product's price as the minimal oneminimal_variant_price = product.pricefor variant in product.variants.all():@@ -21,9 +22,9 @@ def update_product_minimal_variant_price(product, discounts=None, save=True):discounts = fetch_active_discounts()minimal_variant_price = _get_product_minimal_variant_price(product, discounts)if product.minimal_variant_price != minimal_variant_price:- product.minimal_variant_price = minimal_variant_price+ product.minimal_variant_price_amount = minimal_variant_price.amountif save:- product.save(update_fields=["minimal_variant_price"])+ product.save(update_fields=["minimal_variant_price_amount"])return product@@ -40,7 +41,9 @@ def update_products_minimal_variant_prices(products, discounts=None):if updated_product.minimal_variant_price != old_minimal_variant_price:changed_products_to_update.append(updated_product)# Bulk update the changed products- Product.objects.bulk_update(changed_products_to_update, ["minimal_variant_price"])+ Product.objects.bulk_update(+ changed_products_to_update, ["minimal_variant_price_amount"]+ )def update_products_minimal_variant_prices_of_catalogues(diff --git a/saleor/product/utils/variants_picker.py b/saleor/product/utils/variants_picker.pyindex 2a72c8ba14..5d273d2bf0 100644--- a/saleor/product/utils/variants_picker.py+++ b/saleor/product/utils/variants_picker.py@@ -2,7 +2,7 @@ from collections import defaultdictfrom decimal import Decimalfrom typing import Dict, Iterable, List-from django_prices.templatetags import prices_i18n+from django_prices.templatetags import pricesfrom ...core.taxes import display_gross_pricesfrom ...core.utils import to_local_currency@@ -135,9 +135,9 @@ def price_as_dict(price):return {"currency": price.currency,"gross": price.gross.amount,- "grossLocalized": prices_i18n.amount(price.gross),+ "grossLocalized": prices.amount(price.gross),"net": price.net.amount,- "netLocalized": prices_i18n.amount(price.net),+ "netLocalized": prices.amount(price.net),}diff --git a/saleor/settings.py b/saleor/settings.pyindex ac9e219413..102e41ca9e 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -8,7 +8,7 @@ import django_cache_urlimport sentry_sdkfrom django.contrib.messages import constants as messagesfrom django.utils.translation import gettext_lazy as _, pgettext_lazy-from django_prices.templatetags.prices_i18n import get_currency_fraction+from django_prices.utils.formatting import get_currency_fractionfrom sentry_sdk.integrations.django import DjangoIntegration@@ -348,7 +348,10 @@ DEFAULT_COUNTRY = os.environ.get("DEFAULT_COUNTRY", "US")DEFAULT_CURRENCY = os.environ.get("DEFAULT_CURRENCY", "USD")DEFAULT_DECIMAL_PLACES = get_currency_fraction(DEFAULT_CURRENCY)DEFAULT_MAX_DIGITS = 12++# note: having multiple currencies is not supported yetAVAILABLE_CURRENCIES = [DEFAULT_CURRENCY]+COUNTRIES_OVERRIDE = {"EU": pgettext_lazy("Name of political and economical union of european countries", "European Union"@@ -598,10 +601,6 @@ SENTRY_DSN = os.environ.get("SENTRY_DSN")if SENTRY_DSN:sentry_sdk.init(dsn=SENTRY_DSN, integrations=[DjangoIntegration()])--SERIALIZATION_MODULES = {"json": "saleor.core.utils.json_serializer"}--DUMMY = "dummy"BRAINTREE = "braintree"RAZORPAY = "razorpay"diff --git a/saleor/shipping/migrations/0001_initial.py b/saleor/shipping/migrations/0001_initial.pyindex 83fe4f91f1..519493f680 100644--- a/saleor/shipping/migrations/0001_initial.py+++ b/saleor/shipping/migrations/0001_initial.py@@ -3,8 +3,6 @@from __future__ import unicode_literalsimport django.db.models.manager-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -304,11 +302,8 @@ class Migration(migrations.Migration):),("price",- django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- verbose_name="price",+ models.DecimalField(+ decimal_places=2, max_digits=12, verbose_name="price"),),(diff --git a/saleor/shipping/migrations/0008_auto_20180108_0814.py b/saleor/shipping/migrations/0008_auto_20180108_0814.pyindex c6c9e2a360..564086a4df 100644--- a/saleor/shipping/migrations/0008_auto_20180108_0814.py+++ b/saleor/shipping/migrations/0008_auto_20180108_0814.py@@ -3,8 +3,6 @@from __future__ import unicode_literalsimport django.db.models.deletion-import django_prices.models-from django.conf import settingsfrom django.db import migrations, models@@ -287,9 +285,7 @@ class Migration(migrations.Migration):migrations.AlterField(model_name="shippingmethodcountry",name="price",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY, decimal_places=2, max_digits=12- ),+ field=models.DecimalField(decimal_places=2, max_digits=12),),migrations.AlterField(model_name="shippingmethodcountry",diff --git a/saleor/shipping/migrations/0013_auto_20180822_0721.py b/saleor/shipping/migrations/0013_auto_20180822_0721.pyindex 2f3c8f198b..c3720838d8 100644--- a/saleor/shipping/migrations/0013_auto_20180822_0721.py+++ b/saleor/shipping/migrations/0013_auto_20180822_0721.py@@ -3,8 +3,6 @@import django.db.models.deletionimport django_countries.fieldsimport django_measurement.models-import django_prices.models-from django.conf import settingsfrom django.db import migrations, modelsimport saleor.core.weight@@ -66,12 +64,8 @@ class Migration(migrations.Migration):migrations.AddField(model_name="shippingmethod",name="maximum_order_price",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, max_digits=12, null=True),),migrations.AddField(@@ -84,13 +78,8 @@ class Migration(migrations.Migration):migrations.AddField(model_name="shippingmethod",name="minimum_order_price",- field=django_prices.models.MoneyField(- blank=True,- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- null=True,+ field=models.DecimalField(+ blank=True, decimal_places=2, default=0, max_digits=12, null=True),),migrations.AddField(@@ -106,12 +95,7 @@ class Migration(migrations.Migration):migrations.AddField(model_name="shippingmethod",name="price",- field=django_prices.models.MoneyField(- currency=settings.DEFAULT_CURRENCY,- decimal_places=2,- default=0,- max_digits=12,- ),+ field=models.DecimalField(decimal_places=2, default=0, max_digits=12),),migrations.AddField(model_name="shippingmethod",diff --git a/saleor/shipping/migrations/0017_django_price_2.py b/saleor/shipping/migrations/0017_django_price_2.pynew file mode 100644index 0000000000..2da95095f0--- /dev/null+++ b/saleor/shipping/migrations/0017_django_price_2.py@@ -0,0 +1,30 @@+# Generated by Django 2.2.4 on 2019-08-14 09:13++from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [("shipping", "0016_shippingmethod_meta")]++ operations = [+ migrations.RenameField(+ model_name="shippingmethod",+ old_name="maximum_order_price",+ new_name="maximum_order_price_amount",+ ),+ migrations.RenameField(+ model_name="shippingmethod",+ old_name="minimum_order_price",+ new_name="minimum_order_price_amount",+ ),+ migrations.RenameField(+ model_name="shippingmethod", old_name="price", new_name="price_amount"+ ),+ migrations.AddField(+ model_name="shippingmethod",+ name="currency",+ field=models.CharField(default=settings.DEFAULT_CURRENCY, max_length=10),+ ),+ ]diff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex e557fb5581..bee1451889 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -10,7 +10,7 @@ from django_countries.fields import CountryFieldfrom django_measurement.models import MeasurementFieldfrom django_prices.models import MoneyFieldfrom measurement.measures import Weight-from prices import MoneyRange+from prices import Money, MoneyRangefrom ..core.utils import format_moneyfrom ..core.utils.json_serializer import CustomJsonEncoder@@ -33,12 +33,12 @@ def _applicable_weight_based_methods(weight, qs):return qs.filter(min_weight_matched & (no_weight_limit | max_weight_matched))-def _applicable_price_based_methods(price, qs):+def _applicable_price_based_methods(price: Money, qs):"""Return price based shipping methods that are applicable for the given total."""qs = qs.price_based()- min_price_matched = Q(minimum_order_price__lte=price)- no_price_limit = Q(maximum_order_price__isnull=True)- max_price_matched = Q(maximum_order_price__gte=price)+ min_price_matched = Q(minimum_order_price_amount__lte=price.amount)+ no_price_limit = Q(maximum_order_price_amount__isnull=True)+ max_price_matched = Q(maximum_order_price_amount__gte=price.amount)return qs.filter(min_price_matched & (no_price_limit | max_price_matched))@@ -120,7 +120,7 @@ class ShippingMethodQueryset(models.QuerySet):def weight_based(self):return self.filter(type=ShippingMethodType.WEIGHT_BASED)- def applicable_shipping_methods(self, price, weight, country_code):+ def applicable_shipping_methods(self, price: Money, weight, country_code):"""Return the ShippingMethods that can be used on an order with shipment.It is based on the given country code, and by shipping methods that are@@ -131,18 +131,19 @@ class ShippingMethodQueryset(models.QuerySet):qs = self.filter(shipping_zone__countries__contains=country_code,shipping_zone__default=False,+ currency=price.currency,)if not qs.exists():# Otherwise default shipping zone should be used- qs = self.filter(shipping_zone__default=True)+ qs = self.filter(shipping_zone__default=True, currency=price.currency)- qs = qs.prefetch_related("shipping_zone").order_by("price")+ qs = qs.prefetch_related("shipping_zone").order_by("price_amount")price_based_methods = _applicable_price_based_methods(price, qs)weight_based_methods = _applicable_weight_based_methods(weight, qs)return price_based_methods | weight_based_methodsdef applicable_shipping_methods_for_instance(- self, instance: Union["Checkout", "Order"], price, country_code=None+ self, instance: Union["Checkout", "Order"], price: Money, country_code=None):if not instance.is_shipping_required():return None@@ -159,30 +160,38 @@ class ShippingMethodQueryset(models.QuerySet):class ShippingMethod(models.Model):name = models.CharField(max_length=100)type = models.CharField(max_length=30, choices=ShippingMethodType.CHOICES)- price = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ currency = models.CharField(max_length=10, default=settings.DEFAULT_CURRENCY)+ price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=0,)+ price = MoneyField(amount_field="price_amount", currency_field="currency")shipping_zone = models.ForeignKey(ShippingZone, related_name="shipping_methods", on_delete=models.CASCADE)- minimum_order_price = MoneyField(- currency=settings.DEFAULT_CURRENCY,++ minimum_order_price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,default=0,blank=True,null=True,)- maximum_order_price = MoneyField(- currency=settings.DEFAULT_CURRENCY,+ minimum_order_price = MoneyField(+ amount_field="minimum_order_price_amount", currency_field="currency"+ )++ maximum_order_price_amount = models.DecimalField(max_digits=settings.DEFAULT_MAX_DIGITS,decimal_places=settings.DEFAULT_DECIMAL_PLACES,blank=True,null=True,)+ maximum_order_price = MoneyField(+ amount_field="maximum_order_price_amount", currency_field="currency"+ )+minimum_order_weight = MeasurementField(measurement=Weight,unit_choices=WeightUnits.CHOICES,@@ -193,6 +202,7 @@ class ShippingMethod(models.Model):maximum_order_weight = MeasurementField(measurement=Weight, unit_choices=WeightUnits.CHOICES, blank=True, null=True)+meta = JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)objects = ShippingMethodQueryset.as_manager()diff --git a/saleor/static/populatedb_data.json b/saleor/static/populatedb_data.jsonindex 452ac8417d..17a85e0656 100644--- a/saleor/static/populatedb_data.json+++ b/saleor/static/populatedb_data.json@@ -209,7 +209,8 @@"entityMap": {}},"category": 7,- "price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "price_amount": "15.00",+ "currency": "USD","attributes": "{}","updated_at": "2019-03-06T12:47:35.666Z","charge_taxes": true,@@ -243,7 +244,8 @@"entityMap": {}},"category": 7,- "price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "price_amount": "15.00",+ "currency": "USD","attributes": "{}","updated_at": "2019-03-06T12:47:35.878Z","charge_taxes": true,@@ -277,7 +279,8 @@"entityMap": {}},"category": 7,- "price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "price_amount": "15.00",+ "currency": "USD","attributes": "{}","updated_at": "2019-03-06T12:47:36.096Z","charge_taxes": true,@@ -311,7 +314,8 @@"entityMap": {}},"category": 7,- "price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "price_amount": "15.00",+ "currency": "USD","attributes": "{}","updated_at": "2019-03-06T12:47:36.309Z","charge_taxes": true,@@ -345,7 +349,8 @@"entityMap": {}},"category": 7,- "price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "price_amount": "15.00",+ "currency": "USD","attributes": "{}","updated_at": "2019-03-06T12:47:36.514Z","charge_taxes": true,@@ -379,7 +384,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"49\"]}","updated_at": "2019-03-06T12:47:36.727Z","charge_taxes": true,@@ -413,7 +419,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"3\"]}","updated_at": "2019-03-06T12:47:36.885Z","charge_taxes": true,@@ -447,7 +454,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"52\"]}","updated_at": "2019-03-06T12:47:37.040Z","charge_taxes": true,@@ -481,7 +489,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"50\"]}","updated_at": "2019-03-06T12:47:37.201Z","charge_taxes": true,@@ -515,7 +524,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"1\"]}","updated_at": "2019-03-06T12:47:37.363Z","charge_taxes": true,@@ -549,7 +559,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"2\"]}","updated_at": "2019-03-06T12:47:37.517Z","charge_taxes": true,@@ -583,7 +594,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"54\"]}","updated_at": "2019-03-06T12:47:37.679Z","charge_taxes": true,@@ -617,7 +629,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"53\"]}","updated_at": "2019-03-06T12:47:37.844Z","charge_taxes": true,@@ -651,7 +664,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"16\": [\"51\"]}","updated_at": "2019-03-06T12:47:38.007Z","charge_taxes": true,@@ -685,7 +699,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "price_amount": "15.00",+ "currency": "USD","attributes": "{\"20\": [\"67\"]}","updated_at": "2019-03-06T12:47:38.171Z","charge_taxes": true,@@ -719,7 +734,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "price_amount": "15.00",+ "currency": "USD","attributes": "{\"20\": [\"67\"]}","updated_at": "2019-03-06T12:47:38.362Z","charge_taxes": true,@@ -753,7 +769,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.00", "currency": "USD" },+ "price_amount": "3.00",+ "currency": "USD","attributes": "{\"15\": [\"46\"], \"21\": [\"68\"]}","updated_at": "2019-03-06T12:47:38.530Z","charge_taxes": true,@@ -787,7 +804,8 @@"entityMap": {}},"category": 8,- "price": { "_type": "Money", "amount": "3.20", "currency": "USD" },+ "price_amount": "3.20",+ "currency": "USD","attributes": "{\"15\": [\"46\"], \"21\": [\"69\"]}","updated_at": "2019-03-06T12:47:38.875Z","charge_taxes": true,@@ -821,7 +839,8 @@"entityMap": {}},"category": 7,- "price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "price_amount": "20.00",+ "currency": "USD","attributes": "{\"23\": [\"72\"]}","updated_at": "2019-03-06T12:47:39.256Z","charge_taxes": true,@@ -855,7 +874,8 @@"entityMap": {}},"category": 7,- "price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "price_amount": "20.00",+ "currency": "USD","attributes": "{\"23\": [\"72\"]}","updated_at": "2019-03-06T12:47:39.501Z","charge_taxes": true,@@ -889,7 +909,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "59.00", "currency": "USD" },+ "price_amount": "59.00",+ "currency": "USD","attributes": "{}","updated_at": "2019-03-06T12:47:39.769Z","charge_taxes": true,@@ -923,7 +944,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "49.00", "currency": "USD" },+ "price_amount": "49.00",+ "currency": "USD","attributes": "{}","updated_at": "2019-03-06T12:47:40.537Z","charge_taxes": true,@@ -957,7 +979,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:41.280Z","charge_taxes": true,@@ -991,7 +1014,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:41.681Z","charge_taxes": true,@@ -1025,7 +1049,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:41.972Z","charge_taxes": true,@@ -1059,7 +1084,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:42.283Z","charge_taxes": true,@@ -1093,7 +1119,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:42.524Z","charge_taxes": true,@@ -1127,7 +1154,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:42.771Z","charge_taxes": true,@@ -1161,7 +1189,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:43.640Z","charge_taxes": true,@@ -1195,7 +1224,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:44.067Z","charge_taxes": true,@@ -1229,7 +1259,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:44.582Z","charge_taxes": true,@@ -1263,7 +1294,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:45.080Z","charge_taxes": true,@@ -1297,7 +1329,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:45.376Z","charge_taxes": true,@@ -1331,7 +1364,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:45.669Z","charge_taxes": true,@@ -1365,7 +1399,8 @@"entityMap": {}},"category": 9,- "price": { "_type": "Money", "amount": "30.00", "currency": "USD" },+ "price_amount": "30.00",+ "currency": "USD","attributes": "{\"25\": [\"82\"]}","updated_at": "2019-03-06T12:47:45.937Z","charge_taxes": true,@@ -1379,17 +1414,14 @@"fields": {"sku": "546451996","name": "1l",- "price_override": {- "_type": "Money",- "amount": "15.00",- "currency": "USD"- },+ "price_override_amount": "15.00","product": 61,"attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 113,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "5.00", "currency": "USD" },+ "cost_price_amount": "5.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1399,17 +1431,14 @@"fields": {"sku": "546451997","name": "2.5l",- "price_override": {- "_type": "Money",- "amount": "35.00",- "currency": "USD"- },+ "price_override_amount": "35.00","product": 61,"attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 21,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "2.5 kg"}},@@ -1419,17 +1448,14 @@"fields": {"sku": "546451999","name": "5l",- "price_override": {- "_type": "Money",- "amount": "49.00",- "currency": "USD"- },+ "price_override_amount": "49.00","product": 61,"attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 11,"quantity_allocated": 11,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "5.0 kg"}},@@ -1439,17 +1465,14 @@"fields": {"sku": "998223591","name": "1l",- "price_override": {- "_type": "Money",- "amount": "15.00",- "currency": "USD"- },+ "price_override_amount": "15.00","product": 62,"attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 43,"quantity_allocated": 19,- "cost_price": { "_type": "Money", "amount": "5.00", "currency": "USD" },+ "cost_price_amount": "5.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1459,17 +1482,14 @@"fields": {"sku": "998223599","name": "2.5l",- "price_override": {- "_type": "Money",- "amount": "25.00",- "currency": "USD"- },+ "price_override_amount": "25.00","product": 62,"attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 110,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -1479,17 +1499,14 @@"fields": {"sku": "998223594","name": "5l",- "price_override": {- "_type": "Money",- "amount": "49.00",- "currency": "USD"- },+ "price_override_amount": "49.00","product": 62,"attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 125,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "25.00", "currency": "USD" },+ "cost_price_amount": "25.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -1499,17 +1516,14 @@"fields": {"sku": "998223582","name": "1l",- "price_override": {- "_type": "Money",- "amount": "15.00",- "currency": "USD"- },+ "price_override_amount": "15.00","product": 63,"attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 1235,"quantity_allocated": 4,- "cost_price": { "_type": "Money", "amount": "5.00", "currency": "USD" },+ "cost_price_amount": "5.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1519,17 +1533,14 @@"fields": {"sku": "998223583","name": "2.5l",- "price_override": {- "_type": "Money",- "amount": "25.00",- "currency": "USD"- },+ "price_override_amount": "25.00","product": 63,"attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 1222,"quantity_allocated": 11,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "2.5 kg"}},@@ -1539,17 +1550,14 @@"fields": {"sku": "998223584","name": "5l",- "price_override": {- "_type": "Money",- "amount": "49.00",- "currency": "USD"- },+ "price_override_amount": "49.00","product": 63,"attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 472,"quantity_allocated": 27,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "5.0 kg"}},@@ -1559,17 +1567,14 @@"fields": {"sku": "998323582","name": "1l",- "price_override": {- "_type": "Money",- "amount": "15.00",- "currency": "USD"- },+ "price_override_amount": "15.00","product": 64,"attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 991,"quantity_allocated": 5,- "cost_price": { "_type": "Money", "amount": "5.00", "currency": "USD" },+ "cost_price_amount": "5.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1579,17 +1584,14 @@"fields": {"sku": "998323583","name": "2.5l",- "price_override": {- "_type": "Money",- "amount": "30.00",- "currency": "USD"- },+ "price_override_amount": "30.00","product": 64,"attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 760,"quantity_allocated": 9,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "2.5 kg"}},@@ -1599,17 +1601,14 @@"fields": {"sku": "998323584","name": "5l",- "price_override": {- "_type": "Money",- "amount": "49.00",- "currency": "USD"- },+ "price_override_amount": "49.00","product": 64,"attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 578,"quantity_allocated": 7,- "cost_price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "cost_price_amount": "15.00",+ "currency": "USD","weight": "5.0 kg"}},@@ -1619,17 +1618,14 @@"fields": {"sku": "998423582","name": "1l",- "price_override": {- "_type": "Money",- "amount": "15.00",- "currency": "USD"- },+ "price_override_amount": "15.00","product": 65,"attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 427,"quantity_allocated": 16,- "cost_price": { "_type": "Money", "amount": "5.00", "currency": "USD" },+ "cost_price_amount": "5.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1639,17 +1635,14 @@"fields": {"sku": "998423583","name": "2.5l",- "price_override": {- "_type": "Money",- "amount": "30.00",- "currency": "USD"- },+ "price_override_amount": "30.00","product": 65,"attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 513,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "2.5 kg"}},@@ -1659,17 +1652,14 @@"fields": {"sku": "998423585","name": "5l",- "price_override": {- "_type": "Money",- "amount": "49.00",- "currency": "USD"- },+ "price_override_amount": "49.00","product": 65,"attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 155,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "15.00", "currency": "USD" },+ "cost_price_amount": "15.00",+ "currency": "USD","weight": "5.0 kg"}},@@ -1679,13 +1669,14 @@"fields": {"sku": "988323582","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 71,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1221,"quantity_allocated": 10,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1695,17 +1686,14 @@"fields": {"sku": "938323582","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 71,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 177,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -1715,17 +1703,14 @@"fields": {"sku": "988323522","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 71,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 221,"quantity_allocated": 10,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -1735,13 +1720,13 @@"fields": {"sku": "12312312321","name": "",- "price_override": null,+ "price_override_amount": null,"product": 81,"attributes": "{}","track_inventory": true,"quantity": 21244,"quantity_allocated": 13,- "cost_price": null,+ "cost_price_amount": null,"weight": "0.0 kg"}},@@ -1751,13 +1736,13 @@"fields": {"sku": "1231998121","name": "",- "price_override": null,+ "price_override_amount": null,"product": 82,"attributes": "{}","track_inventory": true,"quantity": 12157,"quantity_allocated": 26,- "cost_price": null,+ "cost_price_amount": null,"weight": "0.0 kg"}},@@ -1767,13 +1752,13 @@"fields": {"sku": "98616712","name": "",- "price_override": null,+ "price_override_amount": null,"product": 83,"attributes": "{}","track_inventory": true,"quantity": 12136,"quantity_allocated": 15,- "cost_price": null,+ "cost_price_amount": null,"weight": "0.0 kg"}},@@ -1783,13 +1768,13 @@"fields": {"sku": "98616713","name": "",- "price_override": null,+ "price_override_amount": null,"product": 84,"attributes": "{}","track_inventory": true,"quantity": 975527,"quantity_allocated": 10,- "cost_price": null,+ "cost_price_amount": null,"weight": "0.0 kg"}},@@ -1799,17 +1784,14 @@"fields": {"sku": "698223582","name": "45cm x 45cm",- "price_override": {- "_type": "Money",- "amount": "20.00",- "currency": "USD"- },+ "price_override_amount": "20.00","product": 85,"attributes": "{\"22\": [\"70\"]}","track_inventory": true,"quantity": 9869,"quantity_allocated": 8,- "cost_price": { "_type": "Money", "amount": "11.00", "currency": "USD" },+ "cost_price_amount": "11.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -1819,13 +1801,14 @@"fields": {"sku": "698223581","name": "55cm x 55cm",- "price_override": null,+ "price_override_amount": null,"product": 85,"attributes": "{\"22\": [\"71\"]}","track_inventory": true,"quantity": 687,"quantity_allocated": 16,- "cost_price": { "_type": "Money", "amount": "12.00", "currency": "USD" },+ "cost_price_amount": "12.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -1835,13 +1818,14 @@"fields": {"sku": "987126191","name": "45cm x 45cm",- "price_override": null,+ "price_override_amount": null,"product": 86,"attributes": "{\"22\": [\"70\"]}","track_inventory": true,"quantity": 572,"quantity_allocated": 1,- "cost_price": { "_type": "Money", "amount": "13.00", "currency": "USD" },+ "cost_price_amount": "13.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -1851,13 +1835,14 @@"fields": {"sku": "998223590","name": "55cm x 55cm",- "price_override": null,+ "price_override_amount": null,"product": 86,"attributes": "{\"22\": [\"71\"]}","track_inventory": true,"quantity": 1020,"quantity_allocated": 21,- "cost_price": { "_type": "Money", "amount": "13.00", "currency": "USD" },+ "cost_price_amount": "13.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -1867,13 +1852,14 @@"fields": {"sku": "93855755","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 72,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1218,"quantity_allocated": 7,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1883,17 +1869,14 @@"fields": {"sku": "43226647","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 72,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 178,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -1903,17 +1886,14 @@"fields": {"sku": "80884671","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 72,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 224,"quantity_allocated": 13,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -1923,13 +1903,14 @@"fields": {"sku": "67882967","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 73,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1214,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1939,17 +1920,14 @@"fields": {"sku": "14925419","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 73,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 181,"quantity_allocated": 6,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -1959,17 +1937,14 @@"fields": {"sku": "62426105","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 73,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 223,"quantity_allocated": 12,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -1979,13 +1954,14 @@"fields": {"sku": "45328412","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 74,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1214,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -1995,17 +1971,14 @@"fields": {"sku": "27512590","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 74,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 185,"quantity_allocated": 10,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -2015,17 +1988,14 @@"fields": {"sku": "40636347","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 74,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 225,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -2035,13 +2005,14 @@"fields": {"sku": "43200242","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 75,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1216,"quantity_allocated": 5,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -2051,17 +2022,14 @@"fields": {"sku": "79129513","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 75,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 187,"quantity_allocated": 12,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -2071,17 +2039,14 @@"fields": {"sku": "75799450","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 75,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 225,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -2091,13 +2056,14 @@"fields": {"sku": "3944859","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 76,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1214,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -2107,17 +2073,14 @@"fields": {"sku": "5829405","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 76,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 179,"quantity_allocated": 4,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -2127,17 +2090,14 @@"fields": {"sku": "84725784","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 76,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 238,"quantity_allocated": 27,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -2147,13 +2107,14 @@"fields": {"sku": "70058446","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 77,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1222,"quantity_allocated": 11,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -2163,17 +2124,14 @@"fields": {"sku": "94044081","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 77,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 177,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -2183,17 +2141,14 @@"fields": {"sku": "80696397","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 77,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 221,"quantity_allocated": 10,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -2203,13 +2158,14 @@"fields": {"sku": "60752428","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 78,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1216,"quantity_allocated": 5,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -2219,17 +2175,14 @@"fields": {"sku": "81470859","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 78,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 181,"quantity_allocated": 6,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -2239,17 +2192,14 @@"fields": {"sku": "30635751","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 78,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 228,"quantity_allocated": 17,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -2259,13 +2209,14 @@"fields": {"sku": "57211177","name": "500ml",- "price_override": null,+ "price_override_amount": null,"product": 79,"attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1221,"quantity_allocated": 10,- "cost_price": { "_type": "Money", "amount": "1.00", "currency": "USD" },+ "cost_price_amount": "1.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -2275,17 +2226,14 @@"fields": {"sku": "57423879","name": "1l",- "price_override": {- "_type": "Money",- "amount": "5.00",- "currency": "USD"- },+ "price_override_amount": "5.00","product": 79,"attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 179,"quantity_allocated": 4,- "cost_price": { "_type": "Money", "amount": "1.50", "currency": "USD" },+ "cost_price_amount": "1.50",+ "currency": "USD","weight": "1.0 kg"}},@@ -2295,17 +2243,14 @@"fields": {"sku": "21438542","name": "2l",- "price_override": {- "_type": "Money",- "amount": "7.00",- "currency": "USD"- },+ "price_override_amount": "7.00","product": 79,"attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 229,"quantity_allocated": 18,- "cost_price": { "_type": "Money", "amount": "2.00", "currency": "USD" },+ "cost_price_amount": "2.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -2315,13 +2260,14 @@"fields": {"sku": "398323583","name": "39",- "price_override": null,+ "price_override_amount": null,"product": 87,"attributes": "{\"24\": [\"75\"]}","track_inventory": true,"quantity": 9125,"quantity_allocated": 4,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2331,13 +2277,14 @@"fields": {"sku": "398323584","name": "40",- "price_override": null,+ "price_override_amount": null,"product": 87,"attributes": "{\"24\": [\"76\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2347,13 +2294,14 @@"fields": {"sku": "398323585","name": "41",- "price_override": null,+ "price_override_amount": null,"product": 87,"attributes": "{\"24\": [\"77\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2363,13 +2311,14 @@"fields": {"sku": "398323586","name": "42",- "price_override": null,+ "price_override_amount": null,"product": 87,"attributes": "{\"24\": [\"78\"]}","track_inventory": true,"quantity": 131,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2379,13 +2328,14 @@"fields": {"sku": "398323588","name": "43",- "price_override": null,+ "price_override_amount": null,"product": 87,"attributes": "{\"24\": [\"79\"]}","track_inventory": true,"quantity": 882,"quantity_allocated": 21,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2395,13 +2345,14 @@"fields": {"sku": "993223583","name": "40",- "price_override": null,+ "price_override_amount": null,"product": 88,"attributes": "{\"24\": [\"76\"]}","track_inventory": true,"quantity": 7611,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -2411,13 +2362,14 @@"fields": {"sku": "978223582","name": "41",- "price_override": null,+ "price_override_amount": null,"product": 88,"attributes": "{\"24\": [\"77\"]}","track_inventory": true,"quantity": 977,"quantity_allocated": 6,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "1.0 kg"}},@@ -2427,13 +2379,13 @@"fields": {"sku": "918323583","name": "40",- "price_override": null,+ "price_override_amount": null,"product": 88,"attributes": "{\"24\": [\"76\"]}","track_inventory": true,"quantity": 0,"quantity_allocated": 0,- "cost_price": null,+ "cost_price_amount": null,"weight": "2.0 kg"}},@@ -2443,13 +2395,14 @@"fields": {"sku": "918223582","name": "45",- "price_override": null,+ "price_override_amount": null,"product": 88,"attributes": "{\"24\": [\"81\"]}","track_inventory": true,"quantity": 15,"quantity_allocated": 15,- "cost_price": { "_type": "Money", "amount": "20.00", "currency": "USD" },+ "cost_price_amount": "20.00",+ "currency": "USD","weight": "2.0 kg"}},@@ -2459,13 +2412,14 @@"fields": {"sku": "988323583","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 89,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1213,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2475,13 +2429,14 @@"fields": {"sku": "338223582","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 89,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 7,"quantity_allocated": 6,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2491,13 +2446,14 @@"fields": {"sku": "118223591","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 89,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2507,13 +2463,14 @@"fields": {"sku": "448323583","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 89,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2523,13 +2480,14 @@"fields": {"sku": "3128223583","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 89,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5802,"quantity_allocated": 11,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2539,13 +2497,14 @@"fields": {"sku": "29716755","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 107,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1227,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2555,13 +2514,14 @@"fields": {"sku": "66594736","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 107,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 8,"quantity_allocated": 7,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2571,13 +2531,14 @@"fields": {"sku": "50269944","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 107,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2587,13 +2548,14 @@"fields": {"sku": "31352185","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 107,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2603,13 +2565,14 @@"fields": {"sku": "85364796","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 107,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5817,"quantity_allocated": 26,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2619,13 +2582,14 @@"fields": {"sku": "44026421","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 108,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1217,"quantity_allocated": 4,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2635,13 +2599,14 @@"fields": {"sku": "90892602","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 108,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 4,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2651,13 +2616,14 @@"fields": {"sku": "59014392","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 108,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2667,13 +2633,14 @@"fields": {"sku": "43659438","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 108,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2683,13 +2650,14 @@"fields": {"sku": "60597697","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 108,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5820,"quantity_allocated": 29,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2699,13 +2667,14 @@"fields": {"sku": "26592266","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 109,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1220,"quantity_allocated": 7,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2715,13 +2684,14 @@"fields": {"sku": "36260498","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 109,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 2,"quantity_allocated": 1,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2731,13 +2701,14 @@"fields": {"sku": "37558859","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 109,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2747,13 +2718,14 @@"fields": {"sku": "19402012","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 109,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2763,13 +2735,14 @@"fields": {"sku": "17570141","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 109,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5817,"quantity_allocated": 26,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2779,13 +2752,14 @@"fields": {"sku": "98530976","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 110,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1221,"quantity_allocated": 8,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2795,13 +2769,14 @@"fields": {"sku": "46806935","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 110,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 6,"quantity_allocated": 5,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2811,13 +2786,14 @@"fields": {"sku": "71103052","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 110,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2827,13 +2803,14 @@"fields": {"sku": "84812015","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 110,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2843,13 +2820,14 @@"fields": {"sku": "89820261","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 110,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5816,"quantity_allocated": 25,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2859,13 +2837,14 @@"fields": {"sku": "81115323","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 111,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1215,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2875,13 +2854,14 @@"fields": {"sku": "38254631","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 111,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 5,"quantity_allocated": 4,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2891,13 +2871,14 @@"fields": {"sku": "11511539","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 111,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9821,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2907,13 +2888,14 @@"fields": {"sku": "84192227","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 111,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2923,13 +2905,14 @@"fields": {"sku": "91642659","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 111,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5807,"quantity_allocated": 16,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2939,13 +2922,14 @@"fields": {"sku": "76491340","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 112,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1217,"quantity_allocated": 4,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2955,13 +2939,14 @@"fields": {"sku": "55101176","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 112,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 3,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2971,13 +2956,14 @@"fields": {"sku": "28094954","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 112,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9819,"quantity_allocated": 1,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -2987,13 +2973,14 @@"fields": {"sku": "40232182","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 112,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3003,13 +2990,14 @@"fields": {"sku": "21522631","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 112,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5809,"quantity_allocated": 18,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3019,13 +3007,14 @@"fields": {"sku": "29810068","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 113,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1220,"quantity_allocated": 7,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3035,13 +3024,14 @@"fields": {"sku": "57917658","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 113,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 6,"quantity_allocated": 5,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3051,13 +3041,14 @@"fields": {"sku": "42680611","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 113,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3067,13 +3058,14 @@"fields": {"sku": "72289815","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 113,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3083,13 +3075,14 @@"fields": {"sku": "98653891","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 113,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5817,"quantity_allocated": 26,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3099,13 +3092,14 @@"fields": {"sku": "77306807","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 114,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1213,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3115,13 +3109,14 @@"fields": {"sku": "68848129","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 114,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3131,13 +3126,14 @@"fields": {"sku": "35342696","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 114,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3147,13 +3143,14 @@"fields": {"sku": "98935349","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 114,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3163,13 +3160,14 @@"fields": {"sku": "45179543","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 114,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5805,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3179,13 +3177,14 @@"fields": {"sku": "62783187","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 115,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1216,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3195,13 +3194,14 @@"fields": {"sku": "91406604","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 115,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 3,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3211,13 +3211,14 @@"fields": {"sku": "22119503","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 115,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3227,13 +3228,14 @@"fields": {"sku": "19230637","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 115,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3243,13 +3245,14 @@"fields": {"sku": "61630747","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 115,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5825,"quantity_allocated": 34,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3259,13 +3262,14 @@"fields": {"sku": "15744278","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 116,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1213,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3275,13 +3279,14 @@"fields": {"sku": "21599567","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 116,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 4,"quantity_allocated": 3,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3291,13 +3296,14 @@"fields": {"sku": "65363253","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 116,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9820,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3307,13 +3313,14 @@"fields": {"sku": "51987722","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 116,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3323,13 +3330,14 @@"fields": {"sku": "43313080","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 116,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5805,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3339,13 +3347,14 @@"fields": {"sku": "33963052","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 117,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1218,"quantity_allocated": 5,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3355,13 +3364,14 @@"fields": {"sku": "66846240","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 117,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 11,"quantity_allocated": 10,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3371,13 +3381,14 @@"fields": {"sku": "55365141","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 117,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9823,"quantity_allocated": 5,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3387,13 +3398,14 @@"fields": {"sku": "73186143","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 117,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3403,13 +3415,14 @@"fields": {"sku": "42651772","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 117,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5805,"quantity_allocated": 14,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3419,13 +3432,14 @@"fields": {"sku": "70760297","name": "S",- "price_override": null,+ "price_override_amount": null,"product": 118,"attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1213,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3435,13 +3449,14 @@"fields": {"sku": "36334412","name": "M",- "price_override": null,+ "price_override_amount": null,"product": 118,"attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 10,"quantity_allocated": 9,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3451,13 +3466,14 @@"fields": {"sku": "35994675","name": "L",- "price_override": null,+ "price_override_amount": null,"product": 118,"attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3467,13 +3483,14 @@"fields": {"sku": "10404946","name": "XL",- "price_override": null,+ "price_override_amount": null,"product": 118,"attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 3,"quantity_allocated": 2,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},@@ -3483,13 +3500,14 @@"fields": {"sku": "45507483","name": "XXL",- "price_override": null,+ "price_override_amount": null,"product": 118,"attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5818,"quantity_allocated": 27,- "cost_price": { "_type": "Money", "amount": "10.00", "currency": "USD" },+ "cost_price_amount": "10.00",+ "currency": "USD","weight": "0.0 kg"}},diff --git a/templates/checkout/shipping_method.html b/templates/checkout/shipping_method.htmlindex 58e8e085d2..3480777f15 100644--- a/templates/checkout/shipping_method.html+++ b/templates/checkout/shipping_method.html@@ -12,7 +12,7 @@</div><p><a class="text-uppercase" href="{% url 'checkout:shipping-address' %}">- {% trans "Select other address" %}+ {% trans "Select another address" %}</a></p><hr>diff --git a/templates/checkout/snippets/voucher_form.html b/templates/checkout/snippets/voucher_form.htmlindex 6b0367d877..7ca14d885f 100644--- a/templates/checkout/snippets/voucher_form.html+++ b/templates/checkout/snippets/voucher_form.html@@ -16,7 +16,7 @@</button></form><div class="float-right">- {% discount_as_negative checkout.discount_amount %}+ {% discount_as_negative checkout.discount %}</div>{% else %}<form action="{{ request.path }}?next={{ request.path }}" method="post">diff --git a/templates/dashboard/discount/voucher/list.html b/templates/dashboard/discount/voucher/list.htmlindex d82bd68685..0d20454208 100644--- a/templates/dashboard/discount/voucher/list.html+++ b/templates/dashboard/discount/voucher/list.html@@ -82,8 +82,8 @@{% endif %}</td><td class="right-align">- {% if voucher.min_amount_spent %}- {% price voucher.min_amount_spent %}+ {% if voucher.min_spent %}+ {% price voucher.min_spent %}{% else %}-{% endif %}diff --git a/templates/dashboard/order/detail.html b/templates/dashboard/order/detail.htmlindex 0158888f04..85fe28fb85 100644--- a/templates/dashboard/order/detail.html+++ b/templates/dashboard/order/detail.html@@ -424,7 +424,7 @@{% endif %}<p>{% price order.total.tax %}</p>{% if order.is_draft or order.discount_amount %}- <p>{% discount_as_negative order.discount_amount html=True %}</p>+ <p>{% discount_as_negative order.discount html=True %}</p>{% endif %}<p><strong>{% price order.total.gross %}</strong></p></td>diff --git a/templates/dashboard/order/list.html b/templates/dashboard/order/list.htmlindex 2c63674efb..7aec9b054a 100644--- a/templates/dashboard/order/list.html+++ b/templates/dashboard/order/list.html@@ -1,7 +1,7 @@{% extends "dashboard/base.html" %}{% load i18n %}{% load price from taxed_prices %}-{% load prices_i18n %}+{% load prices %}{% load status %}{% load utils %}{% load static %}diff --git a/templates/dashboard/order/pdf/invoice.html b/templates/dashboard/order/pdf/invoice.htmlindex c72e9d1fce..6e1fb9de03 100644--- a/templates/dashboard/order/pdf/invoice.html+++ b/templates/dashboard/order/pdf/invoice.html@@ -132,7 +132,7 @@{% trans "Discount" context "Order voucher header" %} {% if order.discount_name %}({{ order.translated_discount_name|default:order.discount_name }}){% endif %}</td><td class="right-align">- {% discount_as_negative order.discount_amount html=True %}+ {% discount_as_negative order.discount html=True %}</td></tr>{% endif %}diff --git a/templates/dashboard/product/list.html b/templates/dashboard/product/list.htmlindex 1a6b5fd641..2f553ea0d2 100644--- a/templates/dashboard/product/list.html+++ b/templates/dashboard/product/list.html@@ -62,7 +62,7 @@{% sorting_header 'name' label is_wide=True %}{% trans "Price" context "Products list table header" as label %}- {% sorting_header 'price' label is_wide=True %}+ {% sorting_header 'price_amount' label is_wide=True %}</tr></thead><tbody>diff --git a/templates/materializecssform/field.html b/templates/materializecssform/field.htmlindex 1695498a3a..15a04993eb 100644--- a/templates/materializecssform/field.html+++ b/templates/materializecssform/field.html@@ -87,7 +87,7 @@{% endif %}</label><input type="date" id="{{ field.auto_id }}" class="datepicker" name="{{ field.name }}"- value="{% if field.value %}{{ field.value|date:"Y-m-d" }}{% endif %}" data-value="{% if field.value %}{{ field.value|date:"Y-m-d" }}{% endif %}">+ value="{% if field.value %}{{ field.value|date:"Y-m-d" }}{% endif %}" data-value="{% if field.value %}{{ field.value|date:"Y-m-d"|default:field.value }}{% endif %}">{% for error in field.errors %}<p class="help-block materialize-red-text">{{ error }}diff --git a/templates/order/_ordered_items_table.html b/templates/order/_ordered_items_table.htmlindex 0946a7580a..bf93a0c2b0 100644--- a/templates/order/_ordered_items_table.html+++ b/templates/order/_ordered_items_table.html@@ -129,7 +129,7 @@</div><div class="col-4"><p class="float-right">- {% discount_as_negative order.discount_amount html=True %}+ {% discount_as_negative order.discount html=True %}</p></div></div>diff --git a/templates/price.html b/templates/price.htmlindex 5ad8aa7e5b..72bd284a21 100644--- a/templates/price.html+++ b/templates/price.html@@ -1,4 +1,4 @@-{% load prices_i18n %}{% spaceless %}+{% load prices %}{% spaceless %}{% if is_range %}{% if price.start == price.stop %}{% if html %}diff --git a/templates/product/_price_range.html b/templates/product/_price_range.htmlindex e21d98e208..abae38078b 100644--- a/templates/product/_price_range.html+++ b/templates/product/_price_range.html@@ -1,5 +1,5 @@{% load i18n %}-{% load prices_i18n %}+{% load prices %}<span><span>diff --git a/templates/product/product_list_base.html b/templates/product/product_list_base.htmlindex 43891eb2ca..2bb9531daa 100644--- a/templates/product/product_list_base.html+++ b/templates/product/product_list_base.html@@ -91,7 +91,7 @@{% blocktrans trimmed %}Sort by: <b>name</b>{% endblocktrans %}- {% elif now_sorted_by == 'minimal_variant_price' %}+ {% elif now_sorted_by == 'minimal_variant_price_amount' %}{% blocktrans trimmed %}Sort by: <b>price</b>{% endblocktrans %}diff --git a/templates/templated_email/order/confirm_order.email b/templates/templated_email/order/confirm_order.emailindex 6f672657e4..ae8c6626ae 100644--- a/templates/templated_email/order/confirm_order.email+++ b/templates/templated_email/order/confirm_order.email@@ -18,7 +18,7 @@ Thank you for your order. Below is the list of ordered products. To see your pay{% trans "Subtotal" context "Order confirmation e-mail table header" %}: {% price order.get_subtotal display_gross=order.display_gross_prices html=False %}{% trans "Shipping" context "Order confirmation e-mail table header" %}: {% price order.shipping_price display_gross=order.display_gross_prices html=False %}{% if order.display_gross_prices %}{% trans "Taxes (included)" context "Order confirmation e-mail table header" %}{% else %}{% trans "Taxes" context "Order confirmation e-mail table header" %}{% endif %}: {% price order.total.tax html=False %}-{% if order.discount_amount %}{% trans "Discount:" context "Order confirmation e-mail table header" %} {% discount_as_negative order.discount_amount %}{% endif %}+{% if order.discount_amount %}{% trans "Discount:" context "Order confirmation e-mail table header" %} {% discount_as_negative order.discount %}{% endif %}{% trans "Total" context "Order confirmation e-mail table header" %}: {% price order.total.gross html=False %}{% trans "Billing address" context "Order confirmation e-mail billing address" %}diff --git a/templates/templated_email/source/partials/_order_lines.mjml b/templates/templated_email/source/partials/_order_lines.mjmlindex ef72496429..439bab9af0 100644--- a/templates/templated_email/source/partials/_order_lines.mjml+++ b/templates/templated_email/source/partials/_order_lines.mjml@@ -40,7 +40,7 @@{% trans "Discount" context "E-mail order lines summary table" %}</td><td style="text-align: right;">- {% discount_as_negative order.discount_amount html=True %}+ {% discount_as_negative order.discount html=True %}</td></tr>{% endif %}diff --git a/tests/api/test_checkout_promo_codes.py b/tests/api/test_checkout_promo_codes.pyindex fde1b1e654..7ee58b593e 100644--- a/tests/api/test_checkout_promo_codes.py+++ b/tests/api/test_checkout_promo_codes.py@@ -1,7 +1,8 @@from datetime import date, timedelta+from decimal import Decimalimport graphene-from prices import TaxedMoney+from prices import Money, TaxedMoneyfrom saleor.checkout.utils import add_voucher_to_checkoutfrom saleor.discount import DiscountInfo, VoucherType@@ -73,12 +74,12 @@ def test_checkout_add_voucher_invalid_code(api_client, checkout_with_item):def test_checkout_add_voucher_not_applicable_voucher(- api_client, checkout_with_item, voucher_with_high_min_amount_spent+ api_client, checkout_with_item, voucher_with_high_min_spent_amount):checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)variables = {"checkoutId": checkout_id,- "voucherCode": voucher_with_high_min_amount_spent.code,+ "voucherCode": voucher_with_high_min_spent_amount.code,}data = _mutate_checkout_update_voucher(api_client, variables)@@ -90,8 +91,8 @@ def test_checkout_lines_delete_with_not_applicable_voucher(user_api_client, checkout_with_item, voucher):subtotal = checkout_with_item.get_subtotal()- voucher.min_amount_spent = TaxedMoney(subtotal, subtotal).gross- voucher.save(update_fields=["min_amount_spent"])+ voucher.min_spent = TaxedMoney(subtotal, subtotal).gross+ voucher.save(update_fields=["min_spent_amount", "currency"])add_voucher_to_checkout(checkout_with_item, voucher)assert checkout_with_item.voucher_code == voucher.code@@ -317,7 +318,7 @@ def test_checkout_add_voucher_code_checkout_with_sale(checkout_with_item.refresh_from_db()assert not data["errors"]assert checkout_with_item.voucher_code == voucher_percentage.code- assert checkout_with_item.discount_amount.amount == 1.5+ assert checkout_with_item.discount_amount == Decimal(1.5)def test_checkout_add_specific_product_voucher_code_checkout_with_sale(@@ -325,6 +326,7 @@ def test_checkout_add_specific_product_voucher_code_checkout_with_sale():voucher = voucher_specific_product_typecheckout = checkout_with_item+ expected_discount = Decimal(1.5)assert checkout.get_subtotal() > checkout.get_subtotal(discounts=[discount_info])checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)variables = {"checkoutId": checkout_id, "promoCode": voucher.code}@@ -333,7 +335,8 @@ def test_checkout_add_specific_product_voucher_code_checkout_with_sale(checkout.refresh_from_db()assert not data["errors"]assert checkout.voucher_code == voucher.code- assert checkout.discount_amount.amount == 1.5+ assert checkout.discount_amount == expected_discount+ assert checkout.discount == Money(expected_discount, "USD")def test_checkout_add_products_voucher_code_checkout_with_sale(@@ -354,7 +357,7 @@ def test_checkout_add_products_voucher_code_checkout_with_sale(checkout.refresh_from_db()assert not data["errors"]assert checkout.voucher_code == voucher.code- assert checkout.discount_amount.amount == 1.5+ assert checkout.discount_amount == Decimal(1.5)def test_checkout_add_collection_voucher_code_checkout_with_sale(@@ -376,7 +379,7 @@ def test_checkout_add_collection_voucher_code_checkout_with_sale(checkout.refresh_from_db()assert not data["errors"]assert checkout.voucher_code == voucher.code- assert checkout.discount_amount.amount == 1.5+ assert checkout.discount_amount == Decimal(1.5)def test_checkout_add_category_code_checkout_with_sale(@@ -397,16 +400,16 @@ def test_checkout_add_category_code_checkout_with_sale(checkout.refresh_from_db()assert not data["errors"]assert checkout.voucher_code == voucher.code- assert checkout.discount_amount.amount == 1.5+ assert checkout.discount_amount == Decimal(1.5)def test_checkout_add_voucher_code_not_applicable_voucher(- api_client, checkout_with_item, voucher_with_high_min_amount_spent+ api_client, checkout_with_item, voucher_with_high_min_spent_amount):checkout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)variables = {"checkoutId": checkout_id,- "promoCode": voucher_with_high_min_amount_spent.code,+ "promoCode": voucher_with_high_min_spent_amount.code,}data = _mutate_checkout_add_promo_code(api_client, variables)@@ -448,7 +451,7 @@ def test_checkout_add_many_gift_card_code(def test_checkout_get_total_with_gift_card(api_client, checkout_with_item, gift_card):total = checkout_with_item.get_total()taxed_total = TaxedMoney(total, total)- total_with_gift_card = taxed_total.gross.amount - gift_card.current_balance+ total_with_gift_card = taxed_total.gross.amount - gift_card.current_balance_amountcheckout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)variables = {"checkoutId": checkout_id, "promoCode": gift_card.code}@@ -469,7 +472,7 @@ def test_checkout_get_total_with_many_gift_card()taxed_total = TaxedMoney(total, total)total_with_gift_card = (- taxed_total.gross.amount - gift_card_created_by_staff.current_balance+ taxed_total.gross.amount - gift_card_created_by_staff.current_balance_amount)assert checkout_with_gift_card.gift_cards.count() > 0diff --git a/tests/api/test_core.py b/tests/api/test_core.pyindex e338c78182..de9cf71686 100644--- a/tests/api/test_core.py+++ b/tests/api/test_core.py@@ -97,8 +97,9 @@ def test_mutation_returns_error_field_in_camel_case(query, variables, permissions=[permission_manage_products])content = get_graphql_content(response)- error = content["data"]["productVariantUpdate"]["errors"][0]- assert error["field"] == "costPrice"+ errors = content["data"]["productVariantUpdate"]["errors"]+ assert len(errors) == 1+ assert errors[0]["field"] == "costPriceAmount"def test_reporting_period_to_date():diff --git a/tests/api/test_discount.py b/tests/api/test_discount.pyindex a67d666d58..a595e1b9c5 100644--- a/tests/api/test_discount.py+++ b/tests/api/test_discount.py@@ -159,6 +159,9 @@ mutation voucherCreate(}voucher {type+ minSpent {+ amount+ }minAmountSpent {amount}@@ -200,7 +203,7 @@ def test_create_voucher(staff_api_client, permission_manage_discounts):get_graphql_content(response)voucher = Voucher.objects.get()assert voucher.type == VoucherType.ENTIRE_ORDER- assert voucher.min_amount_spent.amount == Decimal("1.12")+ assert voucher.min_spent_amount == Decimal("1.12")assert voucher.name == "test voucher"assert voucher.code == "testcode123"assert voucher.discount_value_type == DiscountValueType.FIXED@@ -220,7 +223,7 @@ def test_create_voucher_with_empty_code(staff_api_client, permission_manage_disc"code": "","discountValueType": DiscountValueTypeEnum.FIXED.name,"discountValue": 10.12,- "minAmountSpent": 1.12,+ "minSpent": 1.12,"startDate": start_date.isoformat(),"endDate": end_date.isoformat(),"usageLimit": None,diff --git a/tests/api/test_gift_card.py b/tests/api/test_gift_card.pyindex 915b1f7216..f17e7fb694 100644--- a/tests/api/test_gift_card.py+++ b/tests/api/test_gift_card.py@@ -210,7 +210,10 @@ def test_create_gift_card(staff_api_client, customer_user, permission_manage_gifCREATE_GIFT_CARD_MUTATION, variables, permissions=[permission_manage_gift_card])content = get_graphql_content(response)+ errors = content["data"]["giftCardCreate"]["errors"]data = content["data"]["giftCardCreate"]["giftCard"]++ assert not errorsassert data["displayCode"]assert data["user"]["email"] == customer_user.emailassert data["startDate"] == start_date.isoformat()@@ -238,7 +241,10 @@ def test_create_gift_card_with_empty_code(CREATE_GIFT_CARD_MUTATION, variables, permissions=[permission_manage_gift_card])content = get_graphql_content(response)+ errors = content["data"]["giftCardCreate"]["errors"]data = content["data"]["giftCardCreate"]["giftCard"]++ assert not errorsassert len(data["displayCode"]) > 4@@ -256,7 +262,10 @@ def test_create_gift_card_without_code(staff_api_client, permission_manage_gift_CREATE_GIFT_CARD_MUTATION, variables, permissions=[permission_manage_gift_card])content = get_graphql_content(response)+ errors = content["data"]["giftCardCreate"]["errors"]data = content["data"]["giftCardCreate"]["giftCard"]++ assert not errorsassert len(data["displayCode"]) > 4@@ -306,7 +315,10 @@ def test_create_gift_card_without_user(staff_api_client, permission_manage_gift_CREATE_GIFT_CARD_MUTATION, variables, permissions=[permission_manage_gift_card])content = get_graphql_content(response)+ errors = content["data"]["giftCardCreate"]["errors"]data = content["data"]["giftCardCreate"]["giftCard"]++ assert not errorsassert data["initialBalance"]["amount"] == initial_balanceassert data["currentBalance"]["amount"] == initial_balanceassert not data["user"]@@ -330,8 +342,8 @@ def test_create_gift_card_with_incorrect_user_email(CREATE_GIFT_CARD_MUTATION, variables, permissions=[permission_manage_gift_card])content = get_graphql_content(response)- assert content["data"]["giftCardCreate"]["errors"]errors = content["data"]["giftCardCreate"]["errors"]+ assert errorsassert len(errors) == 1assert errors[0]["field"] == "email"assert errors[0]["message"] == "Customer with this email doesn't exist."@@ -393,7 +405,10 @@ def test_update_gift_card(staff_api_client, gift_card, permission_manage_gift_caUPDATE_GIFT_CARD_MUTATION, variables, permissions=[permission_manage_gift_card])content = get_graphql_content(response)+ errors = content["data"]["giftCardUpdate"]["errors"]data = content["data"]["giftCardUpdate"]["giftCard"]++ assert not errorsassert data["id"] == gift_card_idassert data["displayCode"] == gift_card.display_codeassert data["currentBalance"]["amount"] == balancediff --git a/tests/api/test_order.py b/tests/api/test_order.pyindex cff771165a..49c6190187 100644--- a/tests/api/test_order.py+++ b/tests/api/test_order.py@@ -196,7 +196,7 @@ def test_order_query(assert len(order_data["payments"]) == order.payments.count()expected_methods = ShippingMethod.objects.applicable_shipping_methods(- price=order.get_subtotal().gross.amount,+ price=order.get_subtotal().gross,weight=order.get_total_weight(),country_code=order.shipping_address.country.code,)@@ -254,7 +254,9 @@ def test_order_query_gift_cards(gift_card_data = content["data"]["order"]["giftCards"][0]assert gift_card.display_code == gift_card_data["displayCode"]- assert gift_card.current_balance == gift_card_data["currentBalance"]["amount"]+ assert (+ gift_card.current_balance.amount == gift_card_data["currentBalance"]["amount"]+ )def test_order_query_draft_excluded(staff_api_client, permission_manage_orders, orders):@@ -480,6 +482,9 @@ def test_draft_order_create(discountAmount {amount}+ discount {+ amount+ }discountNamelines {productNamediff --git a/tests/api/test_product.py b/tests/api/test_product.pyindex ed62373f6c..8b1a7f2c67 100644--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@ -1993,11 +1993,9 @@ def test_product_variant_price(product.price = Money(amount=product_price, currency="USD")product.save()if variant_override is not None:- product.variants.update(- price_override=Money(amount=variant_override, currency="USD")- )+ product.variants.update(price_override_amount=variant_override, currency="USD")else:- product.variants.update(price_override=None)+ product.variants.update(price_override_amount=None)# Drop other variants# product.variants.exclude(id=variant.pk).delete()@@ -2094,13 +2092,13 @@ def test_report_product_sales(line_a = order_with_lines.lines.get(product_sku=node_a["sku"])assert node_a["quantityOrdered"] == line_a.quantityamount = str(node_a["revenue"]["gross"]["amount"])- assert Decimal(amount) == line_a.quantity * line_a.unit_price_gross.amount+ assert Decimal(amount) == line_a.quantity * line_a.unit_price_gross_amountnode_b = edges[1]["node"]line_b = order_with_lines.lines.get(product_sku=node_b["sku"])assert node_b["quantityOrdered"] == line_b.quantityamount = str(node_b["revenue"]["gross"]["amount"])- assert Decimal(amount) == line_b.quantity * line_b.unit_price_gross.amount+ assert Decimal(amount) == line_b.quantity * line_b.unit_price_gross_amountdef test_variant_revenue_permissions(diff --git a/tests/conftest.py b/tests/conftest.pyindex 340cf2fbd4..636b6223c4 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -116,7 +116,7 @@ def checkout_with_voucher(checkout, product, voucher):variant = product.variants.get()add_variant_to_checkout(checkout, variant, 3)checkout.voucher_code = voucher.code- checkout.discount_amount = Money("20.00", "USD")+ checkout.discount = Money("20.00", "USD")checkout.save()return checkout@@ -126,7 +126,7 @@ def checkout_with_voucher_percentage(checkout, product, voucher_percentage):variant = product.variants.get()add_variant_to_checkout(checkout, variant, 3)checkout.voucher_code = voucher_percentage.code- checkout.discount_amount = Money("3.00", "USD")+ checkout.discount = Money("3.00", "USD")checkout.save()return checkout@@ -727,9 +727,9 @@ def voucher_specific_product_type(voucher_percentage):@pytest.fixture-def voucher_with_high_min_amount_spent():+def voucher_with_high_min_spent_amount():return Voucher.objects.create(- code="mirumee", discount_value=10, min_amount_spent=Money(1000000, "USD")+ code="mirumee", discount_value=10, min_spent=Money(1000000, "USD"))@@ -766,22 +766,26 @@ def gift_card(customer_user, staff_user):return GiftCard.objects.create(code="mirumee_giftcard",user=customer_user,- initial_balance=10,- current_balance=10,+ initial_balance=Money(10, "USD"),+ current_balance=Money(10, "USD"),)@pytest.fixturedef gift_card_used(staff_user):return GiftCard.objects.create(- code="gift_card_used", initial_balance=150, current_balance=100+ code="gift_card_used",+ initial_balance=Money(150, "USD"),+ current_balance=Money(100, "USD"),)@pytest.fixturedef gift_card_created_by_staff(staff_user):return GiftCard.objects.create(- code="mirumee_staff", initial_balance=5, current_balance=5+ code="mirumee_staff",+ initial_balance=Money(5, "USD"),+ current_balance=Money(5, "USD"),)diff --git a/tests/dashboard/test_chips.py b/tests/dashboard/test_chips.pyindex 7b6086a542..9825b1b5c5 100644--- a/tests/dashboard/test_chips.py+++ b/tests/dashboard/test_chips.py@@ -55,7 +55,7 @@ class ModelMultipleChoiceFieldFilterSet(django_filters.FilterSet):class RangeFieldFilterSet(django_filters.FilterSet):price = django_filters.RangeFilter(- label="Price", field_name="price", widget=MoneyRangeWidget+ label="Price", field_name="price_amount", widget=MoneyRangeWidget)diff --git a/tests/dashboard/test_discounts.py b/tests/dashboard/test_discounts.pyindex d49118ce6b..f91c518de3 100644--- a/tests/dashboard/test_discounts.py+++ b/tests/dashboard/test_discounts.py@@ -35,7 +35,7 @@ def test_voucher_shipping_add(admin_client):"type": VoucherType.SHIPPING,"discount_value": "15.99","discount_value_type": DiscountValueType.FIXED,- "shipping-min_amount_spent": "59.99",+ "shipping-min_spent_0": "59.99",}response = admin_client.post(url, data, follow=True)assert response.status_code == 200@@ -49,7 +49,7 @@ def test_voucher_shipping_add(admin_client):assert voucher.end_date.isoformat() == "2018-06-01T05:00:00+00:00"assert voucher.discount_value_type == DiscountValueType.FIXEDassert voucher.discount_value == Decimal("15.99")- assert voucher.min_amount_spent == Money("59.99", "USD")+ assert voucher.min_spent == Money("59.99", "USD")def test_view_sale_add(admin_client, category, collection):@@ -102,22 +102,22 @@ def test_view_sale_add_requires_product_category_or_collection(@pytest.mark.parametrize(- "subtotal, discount_value, discount_type, min_amount_spent, expected_value",+ "subtotal, discount_value, discount_type, min_spent_amount, expected_value",[("100", 10, DiscountValueType.FIXED, None, 10),("100.05", 10, DiscountValueType.PERCENTAGE, 100, 10),],)def test_value_voucher_order_discount(- subtotal, discount_value, discount_type, min_amount_spent, expected_value+ subtotal, discount_value, discount_type, min_spent_amount, expected_value):voucher = Voucher(code="unique",type=VoucherType.ENTIRE_ORDER,discount_value_type=discount_type,discount_value=discount_value,- min_amount_spent=Money(min_amount_spent, "USD")- if min_amount_spent is not None+ min_spent=Money(min_spent_amount, "USD")+ if min_spent_amount is not Noneelse None,)subtotal = Money(subtotal, "USD")@@ -139,7 +139,7 @@ def test_shipping_voucher_order_discount(type=VoucherType.SHIPPING,discount_value_type=discount_type,discount_value=discount_value,- min_amount_spent=None,+ min_spent_amount=None,)subtotal = Money(100, "USD")subtotal = TaxedMoney(net=subtotal, gross=subtotal)@@ -154,7 +154,7 @@ def test_shipping_voucher_order_discount(@pytest.mark.parametrize(- "total, total_quantity, min_amount_spent, min_checkout_items_quantity,"+ "total, total_quantity, min_spent_amount, min_checkout_items_quantity,""voucher_type",[(99, 10, 100, 10, VoucherType.SHIPPING),@@ -169,15 +169,15 @@ def test_shipping_voucher_order_discount(],)def test_shipping_voucher_checkout_discount_not_applicable_returns_zero(- total, total_quantity, min_amount_spent, min_checkout_items_quantity, voucher_type+ total, total_quantity, min_spent_amount, min_checkout_items_quantity, voucher_type):voucher = Voucher(code="unique",type=voucher_type,discount_value_type=DiscountValueType.FIXED,discount_value=10,- min_amount_spent=(- Money(min_amount_spent, "USD") if min_amount_spent is not None else None+ min_spent=(+ Money(min_spent_amount, "USD") if min_spent_amount is not None else None),min_checkout_items_quantity=min_checkout_items_quantity,)@@ -245,7 +245,7 @@ def test_ajax_voucher_list(admin_client, voucher):@pytest.mark.parametrize("voucher_type", ["collection", "category", "product", "entire_order", "shipping"])-def test_voucher_form_min_amount_spent_is_changed_on_edit(+def test_voucher_form_min_spent_amount_is_changed_on_edit(admin_client, product, collection, voucher_type):assert Voucher.objects.count() == 0@@ -261,14 +261,19 @@ def test_voucher_form_min_amount_spent_is_changed_on_edit("product-products": [product.pk],"category-categories": [product.category.pk],"collection-collections": [collection.pk],- "shipping-min_amount_spent": "400",- "product-min_amount_spent": "400",- "category-min_amount_spent": "400",- "collection-min_amount_spent": "400",- "value-min_amount_spent": "400",+ "shipping-min_spent_0": "400",+ "product-min_spent_0": "400",+ "category-min_spent_0": "400",+ "collection-min_spent_0": "400",+ "value-min_spent_0": "400",+ "shipping-min_spent_1": "USD",+ "product-min_spent_1": "USD",+ "category-min_spent_1": "USD",+ "collection-min_spent_1": "USD",+ "value-min_spent_1": "USD",}- data["{}-min_amount_spent".format(voucher_type)] = "800"+ data["{}-min_spent_0".format(voucher_type)] = "800"response = admin_client.post(url, data, follow=True)@@ -283,4 +288,4 @@ def test_voucher_form_min_amount_spent_is_changed_on_edit(assert voucher.end_date.isoformat() == "2019-06-01T05:00:00+00:00"assert voucher.discount_value_type == DiscountValueType.FIXEDassert voucher.discount_value == Decimal("15.99")- assert voucher.min_amount_spent == Money("800", "USD")+ assert voucher.min_spent == Money(800, "USD")diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 466d5b2e96..05f06504f0 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -897,9 +897,9 @@ def test_view_edit_discount(admin_client, draft_order, settings):assert get_redirect_location(response) == redirect_urldraft_order.refresh_from_db()- discount_amount = Money(discount_value, settings.DEFAULT_CURRENCY)- assert draft_order.discount_amount == discount_amount- assert draft_order.total == total_before - discount_amount+ discount = Money(discount_value, settings.DEFAULT_CURRENCY)+ assert draft_order.discount == discount+ assert draft_order.total == total_before - discountdef test_update_order_with_user_addresses(order):@@ -994,17 +994,17 @@ def test_view_order_voucher_edit(admin_client, draft_order, settings, voucher):assert get_redirect_location(response) == redirect_urldraft_order.refresh_from_db()- discount_amount = Money(voucher.discount_value, settings.DEFAULT_CURRENCY)- assert draft_order.discount_amount == discount_amount- assert draft_order.total == total_before - discount_amount+ discount = Money(voucher.discount_value, settings.DEFAULT_CURRENCY)+ assert draft_order.discount == discount+ assert draft_order.total == total_before - discountdef test_view_order_voucher_remove(admin_client, draft_order, settings, voucher):increase_voucher_usage(voucher)draft_order.voucher = voucher- discount_amount = Money(voucher.discount_value, settings.DEFAULT_CURRENCY)- draft_order.discount_amount = discount_amount- draft_order.total -= discount_amount+ discount = Money(voucher.discount_value, settings.DEFAULT_CURRENCY)+ draft_order.discount = discount+ draft_order.total -= discountdraft_order.save()total_before = draft_order.totalurl = reverse("dashboard:order-voucher-remove", kwargs={"order_pk": draft_order.pk})@@ -1019,8 +1019,8 @@ def test_view_order_voucher_remove(admin_client, draft_order, settings, voucher)assert get_redirect_location(response) == redirect_urldraft_order.refresh_from_db()- assert draft_order.discount_amount == zero_money()- assert draft_order.total == total_before + discount_amount+ assert draft_order.discount == zero_money()+ assert draft_order.total == total_before + discountdef test_view_mark_order_as_paid(admin_client, order_with_lines):diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex 49ad4d94b6..8709f9beb7 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -218,7 +218,8 @@ def test_view_product_create(admin_client, product_type, category):data = {"name": "Product","description": "This is product description.",- "price": 10,+ "price_0": 10,+ "price_1": "USD","category": category.pk,"variant-sku": "123","variant-quantity": 2,@@ -239,7 +240,8 @@ def test_view_product_edit(admin_client, product):data = {"name": "Product second name","description": "Product description.",- "price": 10,+ "price_0": 10,+ "price_1": product.price.currency,"category": product.category.pk,"variant-sku": "123","variant-quantity": 10,@@ -1061,7 +1063,8 @@ def test_product_form_change_attributes(db, product, color_attribute):new_author = "Main Tester"data = {"name": product.name,- "price": product.price.amount,+ "price_0": product.price.amount,+ "price_1": product.price.currency,"category": product.category.pk,"description": "description","attribute-{}-{}".format(text_attribute.slug, text_attribute.pk): new_author,@@ -1085,7 +1088,8 @@ def test_product_form_assign_collection_to_product(product):collection = Collection.objects.create(name="test_collections")data = {"name": product.name,- "price": product.price.amount,+ "price_0": product.price.amount,+ "price_1": product.price.currency,"category": product.category.pk,"description": "description","collections": [collection.pk],@@ -1115,7 +1119,8 @@ def test_product_form_sanitize_product_description(product_type, category, setti'<p><a href="www.mirumee.com">link</a></p>'"<p>an <script>evil()</script>example</p>")- data["price"] = 20+ data["price_0"] = 20+ data["price_1"] = "USD"form = ProductForm(data, instance=product)assert form.is_valid()@@ -1138,7 +1143,8 @@ def test_product_form_seo_description(unavailable_product):"HTML <b>shouldn't be removed</b> since it's a simple text field.")data = model_to_dict(unavailable_product)- data["price"] = 20+ data["price_0"] = 20+ data["price_1"] = "USD"data["description"] = "a description"data["seo_description"] = seo_description@@ -1165,11 +1171,13 @@ def test_product_form_seo_description_too_long(unavailable_product):)data = model_to_dict(unavailable_product)- data["price"] = 20+ data["price_0"] = 20+ data["price_1"] = "USD"data["description"] = descriptionform = ProductForm(data, instance=unavailable_product)- assert form.is_valid()+ form.is_valid()+ assert form.errors == {}form.save()new_seo_description = unavailable_product.seo_descriptiondiff --git a/tests/dashboard/test_shipping.py b/tests/dashboard/test_shipping.pyindex fe8b4e8c51..846b8cc4ca 100644--- a/tests/dashboard/test_shipping.py+++ b/tests/dashboard/test_shipping.py@@ -85,14 +85,16 @@ def test_add_default_shipping_zone_form():(20, 20, False),),)-def test_price_shipping_method_form(min_price, max_price, result):+def test_price_shipping_method_form(shipping_method, min_price, max_price, result):data = {"name": "Name","price": 10,- "minimum_order_price": min_price,- "maximum_order_price": max_price,+ "minimum_order_price_0": min_price,+ "minimum_order_price_1": "USD",+ "maximum_order_price_0": max_price,+ "maximum_order_price_1": "USD",}- form = PriceShippingMethodForm(data=data)+ form = PriceShippingMethodForm(data=data, instance=shipping_method)assert form.is_valid() == result@@ -214,7 +216,8 @@ def test_shipping_method_edit(admin_client, shipping_zone):)data = {"name": "DHL",- "price": "50",+ "price_0": "50",+ "price_1": "USD","shipping_zone": shipping_zone.pk,"type": ShippingMethodType.PRICE_BASED,}@@ -222,7 +225,7 @@ def test_shipping_method_edit(admin_client, shipping_zone):assert response.status_code == 200assert ShippingMethod.objects.count() == 1- shipping_price = shipping_zone.shipping_methods.all()[0].price+ shipping_price = shipping_zone.shipping_methods.only("price").first().priceassert shipping_price == Money(50, "USD")diff --git a/tests/dashboard/test_templatetags.py b/tests/dashboard/test_templatetags.pyindex 9da383b54e..18a212957a 100644--- a/tests/dashboard/test_templatetags.py+++ b/tests/dashboard/test_templatetags.py@@ -35,8 +35,8 @@ def test_sorting_header_many_fields(admin_client):assert result["url"] == url + "?sort_by=-name"assert result["is_active"] is True- data = {"sort_by": "price"}+ data = {"sort_by": "price_amount"}response = admin_client.get(url, data)- result = sorting_header(response.context, "price", "Price")- assert result["url"] == url + "?sort_by=-price"+ result = sorting_header(response.context, "price_amount", "Price")+ assert result["url"] == url + "?sort_by=-price_amount"assert result["is_active"] is Truediff --git a/tests/extensions/plugins/test_avatax.py b/tests/extensions/plugins/test_avatax.pyindex 539c76b2ab..c92790549a 100644--- a/tests/extensions/plugins/test_avatax.py+++ b/tests/extensions/plugins/test_avatax.py@@ -122,7 +122,7 @@ def test_calculate_checkout_total(voucher_amount = Money(voucher_amount, "USD")checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()- checkout_with_item.discount_amount = voucher_amount+ checkout_with_item.discount = voucher_amountcheckout_with_item.save()line = checkout_with_item.lines.first()product = line.variant.productdiff --git a/tests/extensions/plugins/test_vatlayer.py b/tests/extensions/plugins/test_vatlayer.pyindex 2be1cc4bd4..c845ed9e5e 100644--- a/tests/extensions/plugins/test_vatlayer.py+++ b/tests/extensions/plugins/test_vatlayer.py@@ -393,7 +393,7 @@ def test_calculate_checkout_total(checkout_with_item.save()voucher_amount = Money(voucher_amount, "USD")checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()- checkout_with_item.discount_amount = voucher_amount+ checkout_with_item.discount = voucher_amountcheckout_with_item.save()line = checkout_with_item.lines.first()product = line.variant.productdiff --git a/tests/settings.py b/tests/settings.pyindex a1093e4b43..012e5d2705 100644--- a/tests/settings.py+++ b/tests/settings.py@@ -45,3 +45,5 @@ USE_JSON_CONTENT = FalsePASSWORD_HASHERS = ["tests.dummy_password_hasher.DummyHasher"]EXTENSIONS_MANAGER = "saleor.extensions.manager.ExtensionsManager"++PLUGINS = []diff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex 1f4f787179..96f8805575 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -715,7 +715,7 @@ def test_create_order_with_gift_card(total_gross_without_gift_cards = (TaxedMoney(subtotal, subtotal)+ TaxedMoney(shipping_price, shipping_price)- - checkout.discount_amount+ - checkout.discount).grossgift_cards_balance = checkout.get_total_gift_cards_balance()@@ -744,7 +744,7 @@ def test_create_order_with_gift_card_partial_use(checkout_total = checkout.get_total()price_without_gift_card = TaxedMoney(net=checkout_total, gross=checkout_total)- gift_card_balance_before_order = gift_card_used.current_balance+ gift_card_balance_before_order = gift_card_used.current_balance_amountcheckout.gift_cards.add(gift_card_used)checkout.save()@@ -758,12 +758,14 @@ def test_create_order_with_gift_card_partial_use()gift_card_used.refresh_from_db()++ expected_old_balance = (+ price_without_gift_card.gross.amount + gift_card_used.current_balance_amount+ )+assert order.gift_cards.count() > 0assert order.total == zero_taxed_money()- assert (- gift_card_balance_before_order- == (price_without_gift_card + gift_card_used.current_balance).gross.amount- )+ assert gift_card_balance_before_order == expected_old_balancedef test_create_order_with_many_gift_cards(@@ -782,8 +784,9 @@ def test_create_order_with_many_gift_cards(checkout_total = checkout.get_total()price_without_gift_card = TaxedMoney(net=checkout_total, gross=checkout_total)- gift_cards_balance_befor_order = (- gift_card_created_by_staff.current_balance + gift_card.current_balance+ gift_cards_balance_before_order = (+ gift_card_created_by_staff.current_balance.amount+ + gift_card.current_balance.amount)checkout.gift_cards.add(gift_card_created_by_staff)@@ -805,7 +808,7 @@ def test_create_order_with_many_gift_cards(assert gift_card_created_by_staff.current_balance == zero_priceassert gift_card.current_balance == zero_priceassert price_without_gift_card.gross.amount == (- gift_cards_balance_befor_order + order.total.gross.amount+ gift_cards_balance_before_order + order.total.gross.amount)@@ -826,7 +829,7 @@ def test_note_in_created_order(request_checkout_with_item, address, customer_use@pytest.mark.parametrize(- "total, min_amount_spent, total_quantity, min_checkout_items_quantity, "+ "total, min_spent_amount, total_quantity, min_checkout_items_quantity, ""discount_value, discount_value_type, expected_value",[(20, 20, 2, 2, 50, DiscountValueType.PERCENTAGE, 10),@@ -837,7 +840,7 @@ def test_note_in_created_order(request_checkout_with_item, address, customer_use)def test_get_discount_for_checkout_value_voucher(total,- min_amount_spent,+ min_spent_amount,total_quantity,min_checkout_items_quantity,discount_value,@@ -849,8 +852,8 @@ def test_get_discount_for_checkout_value_voucher(type=VoucherType.ENTIRE_ORDER,discount_value_type=discount_value_type,discount_value=discount_value,- min_amount_spent=(- Money(min_amount_spent, "USD") if min_amount_spent is not None else None+ min_spent=(+ Money(min_spent_amount, "USD") if min_spent_amount is not None else None),min_checkout_items_quantity=min_checkout_items_quantity,)@@ -876,7 +879,7 @@ def test_get_voucher_discount_for_checkout_voucher_validation(@pytest.mark.parametrize(- "total, total_quantity, discount_value, discount_type, min_amount_spent, "+ "total, total_quantity, discount_value, discount_type, min_spent_amount, ""min_checkout_items_quantity",[("99", 9, 10, DiscountValueType.FIXED, None, 10),@@ -891,7 +894,7 @@ def test_get_discount_for_checkout_value_voucher_not_applicable(total_quantity,discount_value,discount_type,- min_amount_spent,+ min_spent_amount,min_checkout_items_quantity,):voucher = Voucher(@@ -899,8 +902,8 @@ def test_get_discount_for_checkout_value_voucher_not_applicable(type=VoucherType.ENTIRE_ORDER,discount_value_type=discount_type,discount_value=discount_value,- min_amount_spent=(- Money(min_amount_spent, "USD") if min_amount_spent is not None else None+ min_spent=(+ Money(min_spent_amount, "USD") if min_spent_amount is not None else None),min_checkout_items_quantity=min_checkout_items_quantity,)@@ -943,7 +946,7 @@ def test_get_discount_for_checkout_specific_products_voucher(@pytest.mark.parametrize(- "total, total_quantity, discount_value, discount_type, min_amount_spent,"+ "total, total_quantity, discount_value, discount_type, min_spent_amount,""min_checkout_items_quantity",[("99", 9, 10, DiscountValueType.FIXED, None, 10),@@ -959,7 +962,7 @@ def test_get_discount_for_checkout_specific_products_voucher_not_applicable(total_quantity,discount_value,discount_type,- min_amount_spent,+ min_spent_amount,min_checkout_items_quantity,):discounts = []@@ -972,8 +975,8 @@ def test_get_discount_for_checkout_specific_products_voucher_not_applicable(type=VoucherType.SPECIFIC_PRODUCT,discount_value_type=discount_type,discount_value=discount_value,- min_amount_spent=(- Money(min_amount_spent, "USD") if min_amount_spent is not None else None+ min_spent=(+ Money(min_spent_amount, "USD") if min_spent_amount is not None else None),min_checkout_items_quantity=min_checkout_items_quantity,)@@ -1071,7 +1074,7 @@ def test_get_discount_for_checkout_shipping_voucher_limited_countries(monkeypatc@pytest.mark.parametrize("is_shipping_required, shipping_method, discount_value, discount_type,"- "countries, min_amount_spent, min_checkout_items_quantity, subtotal,"+ "countries, min_spent_amount, min_checkout_items_quantity, subtotal,""total_quantity, error_msg",[(@@ -1154,7 +1157,7 @@ def test_get_discount_for_checkout_shipping_voucher_not_applicable(discount_value,discount_type,countries,- min_amount_spent,+ min_spent_amount,min_checkout_items_quantity,subtotal,total_quantity,@@ -1172,8 +1175,8 @@ def test_get_discount_for_checkout_shipping_voucher_not_applicable(type=VoucherType.SHIPPING,discount_value_type=discount_type,discount_value=discount_value,- min_amount_spent=(- Money(min_amount_spent, "USD") if min_amount_spent is not None else None+ min_spent=(+ Money(min_spent_amount, "USD") if min_spent_amount is not None else None),min_checkout_items_quantity=min_checkout_items_quantity,countries=countries,@@ -1247,7 +1250,7 @@ def test_checkout_voucher_form_invalid_voucher_code(def test_checkout_voucher_form_voucher_not_applicable(voucher, request_checkout_with_item):- voucher.min_amount_spent = 200+ voucher.min_spent = Money(200, "USD")voucher.save()form = CheckoutVoucherForm({"voucher": voucher.code}, instance=request_checkout_with_item@@ -1334,7 +1337,7 @@ def test_remove_voucher_from_checkout(checkout_with_voucher, voucher_translationassert not checkout.voucher_codeassert not checkout.discount_nameassert not checkout.translated_discount_name- assert checkout.discount_amount == zero_money()+ assert checkout.discount == zero_money()def test_recalculate_checkout_discount(@@ -1348,7 +1351,7 @@ def test_recalculate_checkout_discount(assert (checkout_with_voucher.translated_discount_name == voucher_translation_fr.name) # noqa- assert checkout_with_voucher.discount_amount == Money("10.00", "USD")+ assert checkout_with_voucher.discount == Money("10.00", "USD")def test_recalculate_checkout_discount_with_sale(@@ -1356,7 +1359,7 @@ def test_recalculate_checkout_discount_with_sale():checkout = checkout_with_voucher_percentagerecalculate_checkout_discount(checkout, [discount_info])- assert checkout.discount_amount == Money("1.50", "USD")+ assert checkout.discount == Money("1.50", "USD")assert checkout.get_total(discounts=[discount_info]) == Money("13.50", "USD")@@ -1364,14 +1367,14 @@ def test_recalculate_checkout_discount_voucher_not_applicable(checkout_with_voucher, voucher):checkout = checkout_with_voucher- voucher.min_amount_spent = 100- voucher.save()+ voucher.min_spent = Money(100, "USD")+ voucher.save(update_fields=["min_spent_amount", "currency"])recalculate_checkout_discount(checkout_with_voucher, None)assert not checkout.voucher_codeassert not checkout.discount_name- assert checkout.discount_amount == zero_money()+ assert checkout.discount == zero_money()def test_recalculate_checkout_discount_expired_voucher(checkout_with_voucher, voucher):@@ -1384,7 +1387,7 @@ def test_recalculate_checkout_discount_expired_voucher(checkout_with_voucher, voassert not checkout.voucher_codeassert not checkout.discount_name- assert checkout.discount_amount == zero_money()+ assert checkout.discount == zero_money()def test_get_checkout_context(checkout_with_voucher):@@ -1396,7 +1399,7 @@ def test_get_checkout_context(checkout_with_voucher):"checkout_lines": [(checkout_with_voucher.lines.first(), line_price)],"checkout_shipping_price": zero_taxed_money(),"checkout_subtotal": line_price,- "checkout_total": line_price - checkout_with_voucher.discount_amount,+ "checkout_total": line_price - checkout_with_voucher.discount,"shipping_required": checkout_with_voucher.is_shipping_required(),"total_with_shipping": TaxedMoneyRange(start=line_price, stop=line_price),}@@ -1527,9 +1530,9 @@ def test_add_voucher_to_checkout(checkout_with_item, voucher):def test_add_voucher_to_checkout_fail(- checkout_with_item, voucher_with_high_min_amount_spent+ checkout_with_item, voucher_with_high_min_spent_amount):with pytest.raises(NotApplicable):- add_voucher_to_checkout(checkout_with_item, voucher_with_high_min_amount_spent)+ add_voucher_to_checkout(checkout_with_item, voucher_with_high_min_spent_amount)assert checkout_with_item.voucher_code is Nonediff --git a/tests/test_discounts.py b/tests/test_discounts.pyindex 94f5106169..00f1c1dd23 100644--- a/tests/test_discounts.py+++ b/tests/test_discounts.py@@ -18,25 +18,19 @@ from saleor.discount.utils import (from saleor.product.models import Product, ProductVariant-def get_min_amount_spent(min_amount_spent):- if min_amount_spent is not None:- return Money(min_amount_spent, "USD")- return None--@pytest.mark.parametrize(- "min_amount_spent, value",+ "min_spent_amount, value",[(Money(5, "USD"), Money(10, "USD")), (Money(10, "USD"), Money(10, "USD"))],)-def test_valid_voucher_min_amount_spent(min_amount_spent, value):+def test_valid_voucher_min_spent_amount(min_spent_amount, value):voucher = Voucher(code="unique",type=VoucherType.SHIPPING,discount_value_type=DiscountValueType.FIXED,- discount_value=Money(10, "USD"),- min_amount_spent=min_amount_spent,+ discount=Money(10, "USD"),+ min_spent=min_spent_amount,)- voucher.validate_min_amount_spent(value)+ voucher.validate_min_spent(value)@pytest.mark.integration@@ -210,7 +204,7 @@ def test_remove_voucher_usage_by_customer_not_exists(voucher):@pytest.mark.parametrize(- "total, min_amount_spent, total_quantity, min_checkout_items_quantity,"+ "total, min_spent_amount, total_quantity, min_checkout_items_quantity,""discount_value_type",[(20, 20, 2, 2, DiscountValueType.PERCENTAGE),@@ -221,17 +215,18 @@ def test_remove_voucher_usage_by_customer_not_exists(voucher):)def test_validate_voucher(total,- min_amount_spent,+ min_spent_amount,total_quantity,min_checkout_items_quantity,discount_value_type,):voucher = Voucher.objects.create(code="unique",+ currency="USD",type=VoucherType.ENTIRE_ORDER,discount_value_type=discount_value_type,discount_value=50,- min_amount_spent=get_min_amount_spent(min_amount_spent),+ min_spent_amount=min_spent_amount,min_checkout_items_quantity=min_checkout_items_quantity,)total_price = Money(total, "USD")@@ -239,7 +234,7 @@ def test_validate_voucher(@pytest.mark.parametrize(- "total, min_amount_spent, total_quantity, min_checkout_items_quantity, "+ "total, min_spent_amount, total_quantity, min_checkout_items_quantity, ""discount_value, discount_value_type",[(20, 50, 2, 10, 50, DiscountValueType.PERCENTAGE),@@ -249,7 +244,7 @@ def test_validate_voucher()def test_validate_voucher_not_applicable(total,- min_amount_spent,+ min_spent_amount,total_quantity,min_checkout_items_quantity,discount_value,@@ -257,10 +252,11 @@ def test_validate_voucher_not_applicable():voucher = Voucher.objects.create(code="unique",+ currency="USD",type=VoucherType.ENTIRE_ORDER,discount_value_type=discount_value_type,discount_value=discount_value,- min_amount_spent=get_min_amount_spent(min_amount_spent),+ min_spent_amount=min_spent_amount,min_checkout_items_quantity=min_checkout_items_quantity,)total_price = Money(total, "USD")diff --git a/tests/test_elasticsearch.py b/tests/test_elasticsearch.pyindex 3e91530e0a..3718559b71 100644--- a/tests/test_elasticsearch.py+++ b/tests/test_elasticsearch.py@@ -1,8 +1,7 @@-from decimal import Decimal-import pytestfrom django.urls import reversefrom elasticsearch_dsl.connections import connections+from prices import Moneyfrom saleor.account.models import Userfrom saleor.order.models import Order@@ -53,7 +52,7 @@ def indexed_products(product_type, category):product = Product.objects.create(pk=object_id,name="Test product " + str(object_id),- price=Decimal(10.0),+ price=Money(10, "USD"),product_type=product_type,category=category,)diff --git a/tests/test_order.py b/tests/test_order.pyindex 2d983059b5..79ec2c0dae 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -37,20 +37,20 @@ def test_total_setter():price = TaxedMoney(net=Money(10, "USD"), gross=Money(15, "USD"))order = models.Order()order.total = price- assert order.total_net == Money(10, "USD")+ assert order.total_net_amount == Decimal(10)assert order.total.net == Money(10, "USD")- assert order.total_gross == Money(15, "USD")+ assert order.total_gross_amount == Decimal(15)assert order.total.gross == Money(15, "USD")assert order.total.tax == Money(5, "USD")def test_order_get_subtotal(order_with_lines):order_with_lines.discount_name = "Test discount"- order_with_lines.discount_amount = order_with_lines.total.gross * Decimal("0.5")+ order_with_lines.discount = order_with_lines.total.gross * Decimal("0.5")recalculate_order(order_with_lines)target_subtotal = order_with_lines.total - order_with_lines.shipping_price- target_subtotal += order_with_lines.discount_amount+ target_subtotal += order_with_lines.discountassert order_with_lines.get_subtotal() == target_subtotal@@ -67,9 +67,7 @@ def test_add_variant_to_order_adds_line_for_new_variant(assert order.lines.count() == lines_before + 1assert line.product_sku == variant.skuassert line.quantity == 1- assert line.unit_price == TaxedMoney(- net=Money("10.00", "USD"), gross=Money("10.00", "USD")- )+ assert line.unit_price == TaxedMoney(net=Money(10, "USD"), gross=Money(10, "USD"))assert line.translated_product_name == variant.display_product(translated=True)diff --git a/tests/test_postgresql_search.py b/tests/test_postgresql_search.pyindex 3b08a6fac7..0fbce5b361 100644--- a/tests/test_postgresql_search.py+++ b/tests/test_postgresql_search.py@@ -2,6 +2,7 @@ from decimal import Decimalimport pytestfrom django.urls import reverse+from prices import Moneyfrom saleor.account.models import Address, Userfrom saleor.order.models import Order@@ -27,7 +28,7 @@ def named_products(category, product_type):product = Product.objects.create(name=name,description=description,- price=Decimal(6.6),+ price=Money(Decimal(6.6), "USD"),product_type=product_type,category=category,)diff --git a/tests/test_product.py b/tests/test_product.pyindex e743f5f953..e6cbe2dace 100644--- a/tests/test_product.py+++ b/tests/test_product.py@@ -1,15 +1,11 @@import datetime-import io-import jsonimport osfrom decimal import Decimalfrom unittest.mock import patchimport pytestfrom bs4 import BeautifulSoup, Tag-from django.core import serializersfrom django.core.exceptions import ValidationError-from django.core.serializers.base import DeserializationErrorfrom django.http import JsonResponsefrom django.template.response import TemplateResponsefrom django.urls import reverse@@ -398,7 +394,9 @@ def test_adding_to_checkout_with_closed_checkout_token(def test_product_filter_before_filtering(authorized_client, product, category):products = (- models.Product.objects.all().filter(category__name=category).order_by("-price")+ models.Product.objects.all()+ .filter(category__name=category)+ .order_by("-price_amount"))url = reverse("product:category", kwargs={"slug": category.slug, "category_id": category.pk}@@ -411,12 +409,17 @@ def test_product_filter_before_filtering(authorized_client, product, category):def test_product_filter_product_exists(authorized_client, product, category):products = (- models.Product.objects.all().filter(category__name=category).order_by("-price")+ models.Product.objects.all()+ .filter(category__name=category)+ .order_by("-price_amount"))url = reverse("product:category", kwargs={"slug": category.slug, "category_id": category.pk})- data = {"minimal_variant_price_min": [""], "minimal_variant_price_max": ["20"]}+ data = {+ "minimal_variant_price_amount_min": [""],+ "minimal_variant_price_amount_max": ["20"],+ }response = authorized_client.get(url, data)@@ -502,7 +505,7 @@ def test_product_filter_form(authorized_client, product, category):products = (models.Product.objects.all().filter(category__name=category)- .order_by("-minimal_variant_price")+ .order_by("-minimal_variant_price_amount"))url = reverse("product:category", kwargs={"slug": category.slug, "category_id": category.pk}@@ -521,12 +524,12 @@ def test_product_filter_sorted_by_price_descending(products = (models.Product.objects.all().filter(category__name=category, is_published=True)- .order_by("-minimal_variant_price")+ .order_by("-minimal_variant_price_amount"))url = reverse("product:category", kwargs={"slug": category.slug, "category_id": category.pk})- data = {"sort_by": "-minimal_variant_price"}+ data = {"sort_by": "-minimal_variant_price_amount"}response = authorized_client.get(url, data)@@ -831,99 +834,6 @@ def test_variant_base_price(product, price_override):assert variant.base_price == variant.price_override-def test_product_json_serialization(product):- product.price = Money("10.00", "USD")- product.save()- data = json.loads(serializers.serialize("json", models.Product.objects.all()))- assert data[0]["fields"]["price"] == {- "_type": "Money",- "amount": "10.00",- "currency": "USD",- }---def test_product_json_deserialization(category, product_type):- product_json = """- [{{- "model": "product.product",- "pk": 60,- "fields": {{- "seo_title": null,- "seo_description": "Future almost cup national.",- "product_type": {product_type_pk},- "name": "Kelly-Clark",- "description": "Future almost cup national",- "category": {category_pk},- "price": {{"_type": "Money", "amount": "35.98", "currency": "USD"}},- "minimal_variant_price":- {{"_type": "Money", "amount": "35.98", "currency": "USD"}},- "publication_date": null,- "is_published": true,- "attributes": "{{\\"9\\": \\"24\\", \\"10\\": \\"26\\"}}",- "updated_at": "2018-07-19T13:30:24.195Z",- "is_featured": false,- "charge_taxes": true,- "tax_rate": "standard"- }}- }}]- """.format(- category_pk=category.pk, product_type_pk=product_type.pk- )- product_deserialized = list(- serializers.deserialize("json", product_json, ignorenonexistent=True)- )[0]- product_deserialized.save()- product = models.Product.objects.first()- assert product.price == Money(Decimal("35.98"), "USD")-- # same test for bytes- product_json_bytes = bytes(product_json, "utf-8")- product_deserialized = list(- serializers.deserialize("json", product_json_bytes, ignorenonexistent=True)- )[0]- product_deserialized.save()- product = models.Product.objects.first()- assert product.price == Money(Decimal("35.98"), "USD")-- # same test for stream- product_json_stream = io.StringIO(product_json)- product_deserialized = list(- serializers.deserialize("json", product_json_stream, ignorenonexistent=True)- )[0]- product_deserialized.save()- product = models.Product.objects.first()- assert product.price == Money(Decimal("35.98"), "USD")---def test_json_no_currency_deserialization(category, product_type):- product_json = """- [{{- "model": "product.product",- "pk": 60,- "fields": {{- "seo_title": null,- "seo_description": "Future almost cup national.",- "product_type": {product_type_pk},- "name": "Kelly-Clark",- "description": "Future almost cup national",- "category": {category_pk},- "price": {{"_type": "Money", "amount": "35.98"}},- "publication_date": null,- "is_published": true,- "attributes": "{{\\"9\\": \\"24\\", \\"10\\": \\"26\\"}}",- "updated_at": "2018-07-19T13:30:24.195Z",- "is_featured": false,- "charge_taxes": true,- "tax_rate": "standard"- }}- }}]- """.format(- category_pk=category.pk, product_type_pk=product_type.pk- )- with pytest.raises(DeserializationError):- list(serializers.deserialize("json", product_json, ignorenonexistent=True))--def test_variant_picker_data_with_translations(product, translated_variant_fr, settings):diff --git a/tests/test_product_attributes.py b/tests/test_product_attributes.pyindex bf8b209aec..1e78ce0b3b 100644--- a/tests/test_product_attributes.py+++ b/tests/test_product_attributes.py@@ -1,6 +1,7 @@from unittest.mock import MagicMock, Mockimport pytest+from prices import Moneyfrom saleor.product.models import Attribute, AttributeValue, Product, ProductTypefrom saleor.product.tasks import _update_variants_names@@ -14,7 +15,10 @@ from saleor.product.utils.attributes import (@pytest.fixture()def product_with_no_attributes(product_type, category):product = Product.objects.create(- name="Test product", price="10.00", product_type=product_type, category=category+ name="Test product",+ price=Money(10, "USD"),+ product_type=product_type,+ category=category,)return productdiff --git a/tests/test_product_minimal_variant_price.py b/tests/test_product_minimal_variant_price.pyindex 74db800b82..3976e37a8c 100644--- a/tests/test_product_minimal_variant_price.py+++ b/tests/test_product_minimal_variant_price.py@@ -184,7 +184,8 @@ def test_dashboard_product_create_view_sets_minimal_variant_price(data = {"name": "Product name","description": "Description.",- "price": "9.99",+ "price_0": "9.99",+ "price_1": "USD","category": category.pk,}@@ -199,14 +200,19 @@ def test_dashboard_product_variant_create_view_updates_minimal_variant_price(admin_client, product):url = reverse("dashboard:variant-add", kwargs={"product_pk": product.pk})- data = {"sku": "ACME/1/2/3", "price_override": "4.99", "quantity": 1}+ data = {+ "sku": "ACME/1/2/3",+ "price_override_0": "4.99",+ "price_override_1": product.currency,+ "quantity": 1,+ }response = admin_client.post(url, data)assert response.status_code == 302product.refresh_from_db()- [old_variant, new_variant] = product.variants.all()+ assert product.variants.count() == 2assert product.minimal_variant_price != product.priceassert product.minimal_variant_price == Money("4.99", "USD")diff --git a/tests/test_shipping.py b/tests/test_shipping.pyindex 848b60be29..5a8265df5e 100644--- a/tests/test_shipping.py+++ b/tests/test_shipping.py@@ -28,25 +28,26 @@ def test_shipping_get_ajax_label(shipping_zone):@pytest.mark.parametrize("price, min_price, max_price, shipping_included",(- (money(10), money(10), money(20), True), # price equal min price- (money(10), money(1), money(10), True), # price equal max price- (money(9), money(10), money(15), False), # price just below min price- (money(10), money(1), money(9), False), # price just above max price- (money(10000000), money(1), None, True), # no max price limit- (money(10), money(5), money(15), True),+ (10, 10, 20, True), # price equal min price+ (10, 1, 10, True), # price equal max price+ (9, 10, 15, False), # price just below min price+ (10, 1, 9, False), # price just above max price+ (10000000, 1, None, True), # no max price limit+ (10, 5, 15, True),),) # regular casedef test_applicable_shipping_methods_price(shipping_zone, price, min_price, max_price, shipping_included):method = shipping_zone.shipping_methods.create(- minimum_order_price=min_price,- maximum_order_price=max_price,+ minimum_order_price_amount=min_price,+ maximum_order_price_amount=max_price,+ currency="USD",type=ShippingMethodType.PRICE_BASED,)assert "PL" in shipping_zone.countriesresult = ShippingMethod.objects.applicable_shipping_methods(- price=price, weight=Weight(kg=0), country_code="PL"+ price=Money(price, "USD"), weight=Weight(kg=0), country_code="PL")assert (method in result) == shipping_included