Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Django 4.0+ #14

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ 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.
- 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.

Expand Down
10 changes: 5 additions & 5 deletions src/inventree_shopify/ShopifyPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
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 _
from django.utils.translation import gettext_lazy as _

from stock.models import StockItem

Expand Down Expand Up @@ -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<location>\d+)/(?P<pk>\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 = {
Expand Down
8 changes: 4 additions & 4 deletions src/inventree_shopify/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand All @@ -33,15 +33,15 @@ 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',),
),
migrations.CreateModel(
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')),
Expand All @@ -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')),
Expand Down
8 changes: 4 additions & 4 deletions src/inventree_shopify/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down Expand Up @@ -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")
)
Expand Down Expand Up @@ -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."""
Expand Down