From 29c3a33f7b23f1205a0120b2a70e50c180752bdc Mon Sep 17 00:00:00 2001 From: Zeke Gustafson Date: Fri, 2 Aug 2024 11:41:15 -0500 Subject: [PATCH 1/6] Replace url with re_path --- src/inventree_shopify/ShopifyPlugin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/inventree_shopify/ShopifyPlugin.py b/src/inventree_shopify/ShopifyPlugin.py index 35f2288..380ba29 100644 --- a/src/inventree_shopify/ShopifyPlugin.py +++ b/src/inventree_shopify/ShopifyPlugin.py @@ -3,7 +3,7 @@ import datetime from django import forms -from django.conf.urls import url +from django.urls import re_path from django.http.response import Http404 from django.shortcuts import redirect, render from django.utils.translation import ugettext_lazy as _ @@ -285,13 +285,13 @@ def _webhook_delete(self, _id): def setup_urls(self): """Returns the URLs defined by this plugin.""" return [ - url( + re_path( r"increase/(?P\d+)/(?P\d+)/", self.view_increase, name="increase-level", ), - url(r"webhook/", self.view_webhooks, name="webhooks"), - url(r"^", self.view_index, name="index"), + re_path(r"webhook/", self.view_webhooks, name="webhooks"), + re_path(r"^", self.view_index, name="index"), ] SETTINGS = { From 0e55433bbf9fd38a7aa546d478ea4c6c84764889 Mon Sep 17 00:00:00 2001 From: Zeke Gustafson Date: Fri, 2 Aug 2024 11:56:39 -0500 Subject: [PATCH 2/6] Fit ugettext_lazy Deprecated by Django --- src/inventree_shopify/ShopifyPlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inventree_shopify/ShopifyPlugin.py b/src/inventree_shopify/ShopifyPlugin.py index 380ba29..2b4f109 100644 --- a/src/inventree_shopify/ShopifyPlugin.py +++ b/src/inventree_shopify/ShopifyPlugin.py @@ -6,7 +6,7 @@ from django.urls import re_path from django.http.response import Http404 from django.shortcuts import redirect, render -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from stock.models import StockItem From a055365ac47dda0037b9635bba511fa514a834a5 Mon Sep 17 00:00:00 2001 From: Zeke Gustafson Date: Fri, 2 Aug 2024 12:40:54 -0500 Subject: [PATCH 3/6] Update Shopify API documentation --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1fd187c..6cfbc88 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,11 @@ Sync changes between Shopify inventory levels (nventory per location) and InvenT 1. Install in your instance via [pip install method](https://docs.inventree.org/en/latest/extend/plugins/install/?h=plugin#plugin-installation-file-pip). 2. Add a private app to your Shopify store. + - Use the scopes: "write_inventory, read_inventory, write_product_listings, read_product_listings, write_products, read_products" 3. Go to the inventree-shopify settings in InvenTree and fill in the settings for the plugin from your new private app. + - Use the "Admin API access token" in "API Passwort" + - Use the "API key" in "API Key" + - USe the "API secret key" in "API Shared Secret" 4. Click the webhooks link in the settings - make sure your instance is reachable for shopify. 5. Open the Shopify plane in InvenTree. You can now link your Shopify inventroy levels to your InvenTree stock items. From 361e9ab9223c7566f450f730599c170472ddff8e Mon Sep 17 00:00:00 2001 From: Zeke Gustafson Date: Fri, 2 Aug 2024 12:56:21 -0500 Subject: [PATCH 4/6] Use BigIntegerFields for Shopify IDs --- src/inventree_shopify/migrations/0001_initial.py | 6 +++--- src/inventree_shopify/models.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/inventree_shopify/migrations/0001_initial.py b/src/inventree_shopify/migrations/0001_initial.py index b2c6402..22f323c 100644 --- a/src/inventree_shopify/migrations/0001_initial.py +++ b/src/inventree_shopify/migrations/0001_initial.py @@ -18,7 +18,7 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Product', fields=[ - ('id', models.IntegerField(primary_key=True, serialize=False, verbose_name='Id')), + ('id', models.BigIntegerField(primary_key=True, serialize=False, verbose_name='Id')), ('title', models.CharField(max_length=250, verbose_name='Title')), ('body_html', models.CharField(max_length=250, verbose_name='Body HTML')), ('vendor', models.CharField(max_length=250, verbose_name='Vendor')), @@ -41,7 +41,7 @@ class Migration(migrations.Migration): name='Variant', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('inventory_item_id', models.IntegerField(unique=True, verbose_name='Inventory item ID')), + ('inventory_item_id', models.BigIntegerField(unique=True, verbose_name='Inventory item ID')), ('title', models.CharField(max_length=250, verbose_name='Title')), ('sku', models.CharField(max_length=250, verbose_name='SKU')), ('barcode', models.CharField(max_length=250, verbose_name='Barcode')), @@ -57,7 +57,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('available', models.IntegerField(verbose_name='Available')), - ('location_id', models.IntegerField(verbose_name='Location ID')), + ('location_id', models.BigIntegerField(verbose_name='Location ID')), ('updated_at', models.DateField(blank=True, null=True, verbose_name='Creation Date')), ('stock_item', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ShopifyInventoryLevel', to='stock.stockitem', verbose_name='StockItem')), ('variant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='levels', to='inventree_shopify.variant', verbose_name='Variant')), diff --git a/src/inventree_shopify/models.py b/src/inventree_shopify/models.py index 08071a4..a539fc5 100644 --- a/src/inventree_shopify/models.py +++ b/src/inventree_shopify/models.py @@ -13,7 +13,7 @@ class Product(models.Model): """A shopify product reference.""" - id = models.IntegerField(primary_key=True, verbose_name=_("Id")) # noqa: A003 + id = models.BigIntegerField(primary_key=True, verbose_name=_("Id")) # noqa: A003 title = models.CharField(max_length=250, verbose_name=_("Title")) body_html = models.CharField(max_length=250, verbose_name=_("Body HTML")) vendor = models.CharField(max_length=250, verbose_name=_("Vendor")) @@ -37,7 +37,7 @@ def __str__(self): class Variant(models.Model): """A shopify product variant reference.""" - inventory_item_id = models.IntegerField( + inventory_item_id = models.BigIntegerField( verbose_name=_("Inventory item ID"), unique=True ) title = models.CharField(max_length=250, verbose_name=_("Title")) @@ -74,7 +74,7 @@ class InventoryLevel(models.Model): """A shopify inventory level reference.""" available = models.IntegerField(verbose_name=_("Available")) - location_id = models.IntegerField(verbose_name=_("Location ID")) + location_id = models.BigIntegerField(verbose_name=_("Location ID")) updated_at = models.DateField( blank=True, null=True, verbose_name=_("Creation Date") ) From 74e5972b4f4a3c374af1125672d39d56cb5ef815 Mon Sep 17 00:00:00 2001 From: Zeke Gustafson Date: Fri, 2 Aug 2024 14:00:35 -0500 Subject: [PATCH 5/6] Update README - additional details on plugin install --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6cfbc88..3a750cc 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Sync changes between Shopify inventory levels (nventory per location) and InvenT ## Installation 1. Install in your instance via [pip install method](https://docs.inventree.org/en/latest/extend/plugins/install/?h=plugin#plugin-installation-file-pip). + - Add "inventree-shopify" to plugins.txt + - Run "invoke update" from inventree-server. See (https://docs.inventree.org/en/latest/start/docker_install/#update-database) 2. Add a private app to your Shopify store. - Use the scopes: "write_inventory, read_inventory, write_product_listings, read_product_listings, write_products, read_products" 3. Go to the inventree-shopify settings in InvenTree and fill in the settings for the plugin from your new private app. From c7940fc94e64d0dd75ecef29228aee68553afed6 Mon Sep 17 00:00:00 2001 From: Zeke Gustafson Date: Tue, 6 Aug 2024 09:40:58 -0500 Subject: [PATCH 6/6] Use BigIntegerField for shopify webhook id --- src/inventree_shopify/migrations/0001_initial.py | 2 +- src/inventree_shopify/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inventree_shopify/migrations/0001_initial.py b/src/inventree_shopify/migrations/0001_initial.py index 22f323c..1788ddf 100644 --- a/src/inventree_shopify/migrations/0001_initial.py +++ b/src/inventree_shopify/migrations/0001_initial.py @@ -33,7 +33,7 @@ class Migration(migrations.Migration): name='ShopifyWebhook', fields=[ ('webhookendpoint_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='common.webhookendpoint')), - ('shopify_webhook_id', models.IntegerField(blank=True, null=True)), + ('shopify_webhook_id', models.BigIntegerField(blank=True, null=True)), ], bases=('common.webhookendpoint',), ), diff --git a/src/inventree_shopify/models.py b/src/inventree_shopify/models.py index a539fc5..c8f3bb3 100644 --- a/src/inventree_shopify/models.py +++ b/src/inventree_shopify/models.py @@ -114,7 +114,7 @@ class ShopifyWebhook(WebhookEndpoint): TOKEN_NAME = "X-Shopify-Hmac-Sha256" # noqa: S105 VERIFICATION_METHOD = VerificationMethod.HMAC - shopify_webhook_id = models.IntegerField(blank=True, null=True) + shopify_webhook_id = models.BigIntegerField(blank=True, null=True) def init(self, request, *args, **kwargs): """Setup for webhook handler."""