Skip to content

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

Add new fields to Channel model (#11713)

Krzysztof Waliczekd8852ab848de
diff --git a/saleor/channel/migrations/0006_order_settings_fields.py b/saleor/channel/migrations/0006_order_settings_fields.py
new file mode 100644
index 0000000000..4f1de06ff6
--- /dev/null
+++ b/saleor/channel/migrations/0006_order_settings_fields.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.2.16 on 2022-12-08 09:00
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("channel", "0005_channel_allocation_strategy"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="channel",
+ name="automatically_confirm_all_new_orders",
+ field=models.BooleanField(default=True, null=True),
+ ),
+ migrations.AddField(
+ model_name="channel",
+ name="automatically_fulfill_non_shippable_gift_card",
+ field=models.BooleanField(default=True, null=True),
+ ),
+ ]
diff --git a/saleor/channel/migrations/0007_order_settings_per_channel.py b/saleor/channel/migrations/0007_order_settings_per_channel.py
new file mode 100644
index 0000000000..73cd5bbc92
--- /dev/null
+++ b/saleor/channel/migrations/0007_order_settings_per_channel.py
@@ -0,0 +1,29 @@
+from django.db import migrations
+
+
+def set_order_settings(apps, schema_editor):
+ SiteSettings = apps.get_model("site", "SiteSettings")
+ Channel = apps.get_model("channel", "Channel")
+
+ site_settings = SiteSettings.objects.first()
+
+ Channel.objects.update(
+ automatically_confirm_all_new_orders=(
+ site_settings.automatically_confirm_all_new_orders
+ ),
+ automatically_fulfill_non_shippable_gift_card=(
+ site_settings.automatically_fulfill_non_shippable_gift_card
+ ),
+ )
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("channel", "0006_order_settings_fields"),
+ ("site", "0032_gift_card_settings"),
+ ]
+
+ operations = [
+ migrations.RunPython(set_order_settings, migrations.RunPython.noop),
+ ]
diff --git a/saleor/channel/models.py b/saleor/channel/models.py
index ecb244f2f5..1314c7b106 100644
--- a/saleor/channel/models.py
+++ b/saleor/channel/models.py
@@ -17,6 +17,11 @@ class Channel(models.Model):
choices=AllocationStrategy.CHOICES,
default=AllocationStrategy.PRIORITIZE_SORTING_ORDER,
)
+ automatically_confirm_all_new_orders = models.BooleanField(default=True, null=True)
+ automatically_fulfill_non_shippable_gift_card = models.BooleanField(
+ default=True,
+ null=True,
+ )
class Meta:
ordering = ("slug",)