Merge branch 'Aufinal/dev_supplier' into 'master'

Ajoute un fournisseur aux données de dev

See merge request !202
This commit is contained in:
Martin Pepin 2017-03-30 19:04:22 +02:00
commit 63cb7b7fd0

View file

@ -12,7 +12,8 @@ from django.core.management import call_command
from gestioncof.management.base import MyBaseCommand
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
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)),
@ -125,8 +126,24 @@ class Command(MyBaseCommand):
amount_error=0
)
# ---
# Fournisseur
# ---
supplier, created = Supplier.objects.get_or_create(name="Panoramix")
if created:
articles = random.sample(list(Article.objects.all()), 40)
to_create = []
for article in articles:
to_create.append(SupplierArticle(
supplier=supplier,
article=article
))
SupplierArticle.objects.bulk_create(to_create)
# ---
# Opérations
# ---
call_command('createopes','100', '7')
call_command('createopes', '100', '7', '--transfers=20')