Skip to content

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

Fix missing permssion in promotion state (#14855)

Filip Owczarekff844e6898f3
diff --git a/saleor/discount/migrations/0051_detach_sale_from_permission.py b/saleor/discount/migrations/0051_detach_sale_from_permission.py
index b52ab70968..6a2de1f04f 100644
--- a/saleor/discount/migrations/0051_detach_sale_from_permission.py
+++ b/saleor/discount/migrations/0051_detach_sale_from_permission.py
@@ -92,4 +92,17 @@ class Migration(migrations.Migration):
""",
reverse_sql=migrations.RunSQL.noop,
),
+ migrations.SeparateDatabaseAndState(
+ state_operations=[
+ migrations.AlterModelOptions(
+ name="promotion",
+ options={
+ "ordering": ("name", "pk"),
+ "permissions": (
+ ("manage_discounts", "Manage sales and vouchers."),
+ ),
+ },
+ ),
+ ],
+ ),
]
diff --git a/saleor/discount/models.py b/saleor/discount/models.py
index 69ace9d877..7a26c9bb8c 100644
--- a/saleor/discount/models.py
+++ b/saleor/discount/models.py
@@ -22,6 +22,7 @@ from ..core.models import ModelWithMetadata
from ..core.utils.editorjs import clean_editor_js
from ..core.utils.json_serializer import CustomJsonEncoder
from ..core.utils.translations import Translation
+from ..permission.enums import DiscountPermissions
from . import (
DiscountType,
DiscountValueType,
@@ -320,6 +321,12 @@ class Promotion(ModelWithMetadata):
class Meta:
ordering = ("name", "pk")
+ permissions = (
+ (
+ DiscountPermissions.MANAGE_DISCOUNTS.codename,
+ "Manage sales and vouchers.",
+ ),
+ )
def is_active(self, date=None):
if date is None: