diff --git a/accounting/migrations/0027_add_account_order.py b/accounting/migrations/0027_add_account_order.py new file mode 100644 index 000000000..9db908edd --- /dev/null +++ b/accounting/migrations/0027_add_account_order.py @@ -0,0 +1,33 @@ +# Generated by Django 2.2.24 on 2023-08-16 00:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("accounting", "0026_rename_hidden_products_field"), + ] + + operations = [ + migrations.AlterModelOptions( + name="product", + options={ + "default_permissions": [], + "ordering": ["ordering", "category"], + "permissions": [ + ("base", "View the Accounting tab"), + ("export_orders", "Export orders"), + ("ths_customer_ids", "Edit companies without THS customer IDs"), + ], + "verbose_name_plural": "Products", + }, + ), + migrations.AddField( + model_name="product", + name="ordering", + field=models.IntegerField( + default=0, + help_text="Order the product. The higher the number, the higher the sorting.", + ), + ), + ] diff --git a/accounting/models.py b/accounting/models.py index bf8a8eaae..b57dbca3d 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -65,6 +65,10 @@ class Product(models.Model): revenue = models.ForeignKey(Revenue, blank=False, on_delete=models.CASCADE) result_center = models.PositiveIntegerField(blank=False, null=False) cost_unit = models.PositiveIntegerField(blank=False, null=False) + ordering = models.IntegerField( + default=0, + help_text="Order the product. The higher the number, the higher the sorting.", + ) category = models.ForeignKey( Category, blank=True, null=True, on_delete=models.CASCADE ) @@ -100,7 +104,7 @@ class Product(models.Model): class Meta: verbose_name_plural = "Products" - ordering = ["category", "name"] + ordering = ["ordering", "category"] default_permissions = [] permissions = [ ("base", "View the Accounting tab"),