Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Expand metric units to support more types of products (#13043)

FremahA99e4b88c3e55
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd428633e8..cca5d813e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ All notable, unreleased changes to this project will be documented in this file.
### Saleor Apps
### Other changes
+- Expand metric units to support more types of products. - #13043 by @FremahA
# 3.14.0
diff --git a/saleor/attribute/migrations/0029_alter_attribute_unit.py b/saleor/attribute/migrations/0029_alter_attribute_unit.py
new file mode 100644
index 0000000000..aba3ea21d8
--- /dev/null
+++ b/saleor/attribute/migrations/0029_alter_attribute_unit.py
@@ -0,0 +1,57 @@
+# Generated by Django 3.2.19 on 2023-06-07 14:48
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("attribute", "0028_attribute_attribute_gin"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="attribute",
+ name="unit",
+ field=models.CharField(
+ blank=True,
+ choices=[
+ ("mm", "mm"),
+ ("cm", "cm"),
+ ("dm", "dm"),
+ ("m", "m"),
+ ("km", "km"),
+ ("ft", "ft"),
+ ("yd", "yd"),
+ ("inch", "inch"),
+ ("sq_mm", "sq_mm"),
+ ("sq_cm", "sq_cm"),
+ ("sq_dm", "sq_dm"),
+ ("sq_m", "sq_m"),
+ ("sq_km", "sq_km"),
+ ("sq_ft", "sq_ft"),
+ ("sq_yd", "sq_yd"),
+ ("sq_inch", "sq_inch"),
+ ("cubic_millimeter", "cubic_millimeter"),
+ ("cubic_centimeter", "cubic_centimeter"),
+ ("cubic_decimeter", "cubic_decimeter"),
+ ("cubic_meter", "cubic_meter"),
+ ("liter", "liter"),
+ ("cubic_foot", "cubic_foot"),
+ ("cubic_inch", "cubic_inch"),
+ ("cubic_yard", "cubic_yard"),
+ ("qt", "qt"),
+ ("pint", "pint"),
+ ("fl_oz", "fl_oz"),
+ ("acre_in", "acre_in"),
+ ("acre_ft", "acre_ft"),
+ ("g", "g"),
+ ("lb", "lb"),
+ ("oz", "oz"),
+ ("kg", "kg"),
+ ("tonne", "tonne"),
+ ],
+ max_length=100,
+ null=True,
+ ),
+ ),
+ ]
diff --git a/saleor/core/units.py b/saleor/core/units.py
index 9cd2037ff6..99a1311a31 100644
--- a/saleor/core/units.py
+++ b/saleor/core/units.py
@@ -1,5 +1,7 @@
class DistanceUnits:
+ MM = "mm"
CM = "cm"
+ DM = "dm"
M = "m"
KM = "km"
FT = "ft"
@@ -7,7 +9,9 @@ class DistanceUnits:
INCH = "inch"
CHOICES = [
+ (MM, "Millimeter"),
(CM, "Centimeter"),
+ (DM, "Decimeter"),
(M, "Meter"),
(KM, "Kilometers"),
(FT, "Feet"),
@@ -17,7 +21,9 @@ class DistanceUnits:
class AreaUnits:
+ SQ_MM = "sq_mm"
SQ_CM = "sq_cm"
+ SQ_DM = "sq_dm"
SQ_M = "sq_m"
SQ_KM = "sq_km"
SQ_FT = "sq_ft"
@@ -25,7 +31,9 @@ class AreaUnits:
SQ_INCH = "sq_inch"
CHOICES = [
+ (SQ_MM, "Square millimeter"),
(SQ_CM, "Square centimeters"),
+ (SQ_DM, "Square decimeter"),
(SQ_M, "Square meters"),
(SQ_KM, "Square kilometers"),
(SQ_FT, "Square feet"),
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index c255ae1de3..26d95cbc5d 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -5960,13 +5960,17 @@ enum AttributeTypeEnum @doc(category: "Attributes") {
"""An enumeration."""
enum MeasurementUnitsEnum {
+ MM
CM
+ DM
M
KM
FT
YD
INCH
+ SQ_MM
SQ_CM
+ SQ_DM
SQ_M
SQ_KM
SQ_FT
@@ -27028,7 +27032,9 @@ union IssuingPrincipal = App | User
"""An enumeration."""
enum DistanceUnitsEnum {
+ MM
CM
+ DM
M
KM
FT
@@ -27038,7 +27044,9 @@ enum DistanceUnitsEnum {
"""An enumeration."""
enum AreaUnitsEnum {
+ SQ_MM
SQ_CM
+ SQ_DM
SQ_M
SQ_KM
SQ_FT