feat(orders): add recipient management and enhance order forms
- Introduced Recipient model to manage order recipients separately from customers. - Updated Order model to link to Recipient, replacing recipient_name and recipient_phone fields. - Enhanced OrderForm to include recipient selection modes: customer, history, and new. - Added AJAX endpoint to fetch recipient history for customers. - Updated admin interface to manage recipients and display recipient information in order details. - Refactored address handling to accommodate new recipient logic. - Improved demo order creation to include random recipients.
This commit is contained in:
@@ -10,7 +10,7 @@ from datetime import datetime, timedelta
|
||||
import random
|
||||
from decimal import Decimal
|
||||
|
||||
from orders.models import Order, OrderItem, Address
|
||||
from orders.models import Order, OrderItem, Address, Recipient
|
||||
from customers.models import Customer
|
||||
from inventory.models import Warehouse
|
||||
from products.models import Product
|
||||
@@ -133,8 +133,14 @@ class Command(BaseCommand):
|
||||
# Дополнительная информация
|
||||
if random.random() > 0.7: # 30% - подарок другому человеку
|
||||
order.customer_is_recipient = False
|
||||
order.recipient_name = f"Получатель {i+1}"
|
||||
order.recipient_phone = f"+7{random.randint(9000000000, 9999999999)}"
|
||||
# Создаем получателя
|
||||
recipient_name = f"Получатель {i+1}"
|
||||
recipient_phone = f"+7{random.randint(9000000000, 9999999999)}"
|
||||
recipient, created = Recipient.objects.get_or_create(
|
||||
name=recipient_name,
|
||||
phone=recipient_phone
|
||||
)
|
||||
order.recipient = recipient
|
||||
|
||||
if random.random() > 0.8: # 20% анонимных
|
||||
order.is_anonymous = True
|
||||
|
||||
Reference in New Issue
Block a user