diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index 255213d..c5c0f96 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 125d336..d3ebbac 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 130daf1..bbd2353 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from .models import Device from .models import ( Category, Unit, Product, Customer, Supplier, Sale, SaleItem, SalePayment, @@ -87,3 +88,9 @@ class LoyaltyTransactionAdmin(admin.ModelAdmin): list_display = ('customer', 'transaction_type', 'points', 'created_at') list_filter = ('transaction_type', 'created_at') search_fields = ('customer__name',) + +@admin.register(Device) +class DeviceAdmin(admin.ModelAdmin): + list_display = ('name', 'device_type', 'connection_type', 'ip_address', 'is_active') + list_filter = ('device_type', 'connection_type', 'is_active') + search_fields = ('name', 'ip_address') diff --git a/core/migrations/0024_device.py b/core/migrations/0024_device.py new file mode 100644 index 0000000..c12b375 --- /dev/null +++ b/core/migrations/0024_device.py @@ -0,0 +1,27 @@ +# Generated by Django 5.2.7 on 2026-02-05 12:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0023_alter_product_min_stock_level_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='Device', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100, verbose_name='Device Name')), + ('device_type', models.CharField(choices=[('printer', 'Printer'), ('scanner', 'Scanner'), ('scale', 'Weight Scale'), ('display', 'Customer Display'), ('other', 'Other')], max_length=20, verbose_name='Device Type')), + ('connection_type', models.CharField(choices=[('network', 'Network (IP)'), ('usb', 'USB'), ('bluetooth', 'Bluetooth')], default='network', max_length=20, verbose_name='Connection Type')), + ('ip_address', models.GenericIPAddressField(blank=True, null=True, verbose_name='IP Address')), + ('port', models.PositiveIntegerField(blank=True, null=True, verbose_name='Port')), + ('is_active', models.BooleanField(default=True, verbose_name='Active')), + ('config_json', models.JSONField(blank=True, help_text='Additional driver configuration in JSON format', null=True, verbose_name='Configuration')), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/core/migrations/__pycache__/0024_device.cpython-311.pyc b/core/migrations/__pycache__/0024_device.cpython-311.pyc new file mode 100644 index 0000000..d4cf2e1 Binary files /dev/null and b/core/migrations/__pycache__/0024_device.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 48f0c54..886a0a8 100644 --- a/core/models.py +++ b/core/models.py @@ -375,6 +375,33 @@ class SystemSetting(models.Model): def __str__(self): return self.business_name + +class Device(models.Model): + DEVICE_TYPES = [ + ('printer', _('Printer')), + ('scanner', _('Scanner')), + ('scale', _('Weight Scale')), + ('display', _('Customer Display')), + ('other', _('Other')), + ] + CONNECTION_TYPES = [ + ('network', _('Network (IP)')), + ('usb', _('USB')), + ('bluetooth', _('Bluetooth')), + ] + + name = models.CharField(_("Device Name"), max_length=100) + device_type = models.CharField(_("Device Type"), max_length=20, choices=DEVICE_TYPES) + connection_type = models.CharField(_("Connection Type"), max_length=20, choices=CONNECTION_TYPES, default='network') + ip_address = models.GenericIPAddressField(_("IP Address"), blank=True, null=True) + port = models.PositiveIntegerField(_("Port"), blank=True, null=True) + is_active = models.BooleanField(_("Active"), default=True) + config_json = models.JSONField(_("Configuration"), blank=True, null=True, help_text=_("Additional driver configuration in JSON format")) + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"{self.name} ({self.get_device_type_display()})" + class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile") image = models.ImageField(_("Profile Picture"), upload_to="profile_pics/", blank=True, null=True)