refactor: стандартизация моделей документов перемещения
Приведение к единому паттерну именования документов: - TransferBatch → TransferDocument - TransferItem → TransferDocumentItem - Удалена устаревшая модель Transfer (одиночные перемещения) - Удалена неиспользуемая модель StockMovement Изменения: - models.py: переименование классов, обновление related_names - admin.py: удаление регистраций Transfer/StockMovement - forms.py: обновление TransferHeaderForm - views/transfer.py: обновление всех view классов - templates: замена transfer_batch → transfer_document - urls.py: удаление путей для movements - views/__init__.py: удаление импорта StockMovementListView - views/movements.py: удален файл Миграция: 0005_refactor_transfer_models - RenameModel операции для сохранения данных - DeleteModel для Transfer и StockMovement Единый паттерн: *Document + *DocumentItem (WriteOffDocument, IncomingDocument, TransferDocument) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,11 +5,11 @@ from django.db.models import Sum
|
||||
from decimal import Decimal
|
||||
|
||||
from inventory.models import (
|
||||
Warehouse, StockBatch, Sale, WriteOff, Transfer,
|
||||
Inventory, InventoryLine, Reservation, Stock, StockMovement,
|
||||
Warehouse, StockBatch, Sale, WriteOff,
|
||||
Inventory, InventoryLine, Reservation, Stock,
|
||||
SaleBatchAllocation, Showcase, WriteOffDocument, WriteOffDocumentItem,
|
||||
IncomingDocument, IncomingDocumentItem, Transformation, TransformationInput,
|
||||
TransformationOutput
|
||||
TransformationOutput, TransferDocument, TransferDocumentItem
|
||||
)
|
||||
|
||||
|
||||
@@ -166,28 +166,6 @@ class WriteOffAdmin(admin.ModelAdmin):
|
||||
reason_display.short_description = 'Причина'
|
||||
|
||||
|
||||
# ===== TRANSFER =====
|
||||
@admin.register(Transfer)
|
||||
class TransferAdmin(admin.ModelAdmin):
|
||||
list_display = ('batch', 'from_warehouse', 'to_warehouse', 'quantity', 'date')
|
||||
list_filter = ('date', 'from_warehouse', 'to_warehouse')
|
||||
search_fields = ('batch__product__name', 'document_number')
|
||||
date_hierarchy = 'date'
|
||||
fieldsets = (
|
||||
('Перемещение', {
|
||||
'fields': ('batch', 'from_warehouse', 'to_warehouse', 'quantity', 'new_batch')
|
||||
}),
|
||||
('Документ', {
|
||||
'fields': ('document_number',)
|
||||
}),
|
||||
('Дата', {
|
||||
'fields': ('date',),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
)
|
||||
readonly_fields = ('date', 'new_batch')
|
||||
|
||||
|
||||
# ===== INVENTORY LINE (INLINE) =====
|
||||
class InventoryLineInline(admin.TabularInline):
|
||||
model = InventoryLine
|
||||
@@ -317,16 +295,6 @@ class StockAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ('quantity_available', 'quantity_reserved', 'updated_at')
|
||||
|
||||
|
||||
# ===== STOCK MOVEMENT (для аудита) =====
|
||||
@admin.register(StockMovement)
|
||||
class StockMovementAdmin(admin.ModelAdmin):
|
||||
list_display = ('product', 'change', 'reason', 'order', 'created_at')
|
||||
list_filter = ('reason', 'created_at')
|
||||
search_fields = ('product__name', 'order__order_number')
|
||||
date_hierarchy = 'created_at'
|
||||
readonly_fields = ('created_at',)
|
||||
|
||||
|
||||
# ===== WRITEOFF DOCUMENT (документы списания) =====
|
||||
class WriteOffDocumentItemInline(admin.TabularInline):
|
||||
model = WriteOffDocumentItem
|
||||
|
||||
Reference in New Issue
Block a user