Implement flexible order status management system
Features: - Created OrderStatus model for managing statuses per tenant - Added system-level statuses: draft, new, confirmed, in_assembly, in_delivery, completed, return, cancelled - Implemented CRUD views for managing order statuses - Created OrderStatusService with status transitions and business logic hooks - Updated Order model to use ForeignKey to OrderStatus - Added is_returned flag for tracking returned orders - Updated filters to work with new OrderStatus model - Created management command for status initialization - Added HTML templates for status list, form, and confirmation - Fixed views.py to use OrderStatus instead of removed STATUS_CHOICES 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Generated by Django 5.0.10 on 2025-11-09 22:18
|
||||
# Generated by Django 5.0.10 on 2025-11-13 13:12
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
@@ -26,6 +26,26 @@ class Migration(migrations.Migration):
|
||||
name='product_kit',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='order_items', to='products.productkit', verbose_name='Комплект товаров'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='orderstatus',
|
||||
name='created_by',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_order_statuses', to=settings.AUTH_USER_MODEL, verbose_name='Создано'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='orderstatus',
|
||||
name='updated_by',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='updated_order_statuses', to=settings.AUTH_USER_MODEL, verbose_name='Последнее изменение'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='order',
|
||||
name='status',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='orders', to='orders.orderstatus', verbose_name='Статус заказа'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='historicalorder',
|
||||
name='status',
|
||||
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='orders.orderstatus', verbose_name='Статус заказа'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='payment',
|
||||
name='created_by',
|
||||
@@ -36,13 +56,37 @@ class Migration(migrations.Migration):
|
||||
name='order',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='orders.order', verbose_name='Заказ'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderitem',
|
||||
index=models.Index(fields=['order'], name='orders_orde_order_i_5d347b_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderitem',
|
||||
index=models.Index(fields=['product'], name='orders_orde_product_32ff41_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderitem',
|
||||
index=models.Index(fields=['product_kit'], name='orders_orde_product_925b51_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderstatus',
|
||||
index=models.Index(fields=['code'], name='orders_orde_code_5e1ef7_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderstatus',
|
||||
index=models.Index(fields=['is_system'], name='orders_orde_is_syst_2f5b85_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderstatus',
|
||||
index=models.Index(fields=['order'], name='orders_orde_order_2e2930_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='order',
|
||||
index=models.Index(fields=['customer'], name='orders_orde_custome_59b6fb_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='order',
|
||||
index=models.Index(fields=['status'], name='orders_orde_status_c6dd84_idx'),
|
||||
index=models.Index(fields=['status'], name='orders_orde_status__eb4f00_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='order',
|
||||
@@ -65,16 +109,8 @@ class Migration(migrations.Migration):
|
||||
index=models.Index(fields=['order_number'], name='orders_orde_order_n_f3ada5_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderitem',
|
||||
index=models.Index(fields=['order'], name='orders_orde_order_i_5d347b_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderitem',
|
||||
index=models.Index(fields=['product'], name='orders_orde_product_32ff41_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='orderitem',
|
||||
index=models.Index(fields=['product_kit'], name='orders_orde_product_925b51_idx'),
|
||||
model_name='order',
|
||||
index=models.Index(fields=['is_custom_delivery_cost'], name='orders_orde_is_cust_108e98_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='payment',
|
||||
|
||||
Reference in New Issue
Block a user