Skip to content

Commit

Permalink
feat: Add ordering for products (#925)
Browse files Browse the repository at this point in the history
## Describe your changes

Fixes: #

## Checklist before requesting review

- [ ] Feature/fix PRs should add one atomic (as small as possible)
feature or fix.
- [ ] The code compiles and all the tests pass.
  • Loading branch information
didrikmunther authored Aug 15, 2023
1 parent 881e295 commit 295e543
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
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

0 comments on commit 295e543

Please sign in to comment.