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

feat: Add ordering for products #925

Merged
merged 2 commits into from
Aug 15, 2023
Merged
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
33 changes: 33 additions & 0 deletions accounting/migrations/0027_add_account_order.py
Original file line number Diff line number Diff line change
@@ -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.",
),
),
]
6 changes: 5 additions & 1 deletion accounting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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"),
Expand Down
Loading