wherehouse: fix stock movemend model field number which is auto agrement feature

This commit is contained in:
behruz-dev
2025-11-01 15:20:12 +05:00
parent b3845d8d74
commit a2f23fb601
3 changed files with 4 additions and 2 deletions

View File

@@ -13,8 +13,9 @@ class StockMovemendProductInline(admin.TabularInline):
@admin.register(StockMovemend) @admin.register(StockMovemend)
class StockMovemendAdmin(admin.ModelAdmin): class StockMovemendAdmin(admin.ModelAdmin):
list_display = ['id', 'wherehouse_to', 'wherehouse_from', 'movemend_type'] list_display = ['id', "number", 'wherehouse_to', 'wherehouse_from', 'movemend_type']
inlines = [StockMovemendProductInline] inlines = [StockMovemendProductInline]
ordering = ('-number',)
@admin.register(StockMovmendProduct) @admin.register(StockMovmendProduct)

View File

@@ -0,0 +1 @@
from .stock_movemend import *

View File

@@ -8,4 +8,4 @@ def set_stock_movemend_number(sender, instance, created, **kwargs):
if created: if created:
last_party = StockMovemend.objects.order_by('number').last() last_party = StockMovemend.objects.order_by('number').last()
instance.number = (last_party.number + 1) if last_party else 1 instance.number = (last_party.number + 1) if last_party else 1
instance.save(update_fields=["number"]) instance.save(update_fields=["number"])