Add supplier to dev data

This commit is contained in:
Ludovic Stephan 2017-03-29 23:16:40 -03:00
parent f32f83db75
commit 95c59de4fc

View file

@ -12,7 +12,8 @@ from django.core.management import call_command
from gestioncof.management.base import MyBaseCommand from gestioncof.management.base import MyBaseCommand
from gestioncof.models import CofProfile from gestioncof.models import CofProfile
from kfet.models import (Account, Checkout, CheckoutStatement) from kfet.models import (Account, Checkout, CheckoutStatement, Supplier,
SupplierArticle, Article)
# Où sont stockés les fichiers json # Où sont stockés les fichiers json
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)),
@ -125,8 +126,26 @@ class Command(MyBaseCommand):
amount_error=0 amount_error=0
) )
# ---
# Fournisseur
# ---
supplier, created = Supplier.objects.get_or_create(name="Panoramix")
if created:
articles = Article.objects.filter(category__name="Autres Bieres")
if not articles.exists():
articles = random.sample(Article.objects.all(), 30)
to_create = []
for article in articles:
to_create.append(SupplierArticle(
supplier=supplier,
article=article
))
SupplierArticle.objects.bulk_create(to_create)
# --- # ---
# Opérations # Opérations
# --- # ---
call_command('createopes','100', '7') call_command('createopes', '100', '7', '--transfers=20')