15 lines
705 B
Python
15 lines
705 B
Python
from django.core.management.base import BaseCommand
|
|
from stock.models import PreparationOrder
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "Régénère les QR codes de tous les bons de préparation (pour encoder l'URL complète)"
|
|
|
|
def handle(self, *args, **options):
|
|
orders = PreparationOrder.objects.all()
|
|
total = orders.count()
|
|
self.stdout.write(f"Régénération des QR codes pour {total} bon(s) de préparation...")
|
|
for order in orders:
|
|
order.generate_qr_code()
|
|
PreparationOrder.objects.filter(pk=order.pk).update(qr_code=order.qr_code.name)
|
|
self.stdout.write(self.style.SUCCESS(f"✓ {total} QR code(s) régénéré(s) avec succès."))
|