Création d'un inventaire avec stock initial lors de la création d'un

article
This commit is contained in:
Aurélien Delobelle 2016-08-30 17:16:00 +02:00
parent 3c5f8c49aa
commit fefa6ca5e2

View file

@ -567,6 +567,17 @@ class ArticleCreate(SuccessMessageMixin, CreateView):
SupplierArticle.objects.create(
article = article, supplier = supplier)
# Inventaire avec stock initial
inventory = Inventory()
inventory.by = self.request.user.profile.account_kfet
inventory.save()
InventoryArticle.objects.create(
inventory = inventory,
article = article,
stock_old = article.stock,
stock_new = article.stock,
)
# Creating
return super(ArticleCreate, self).form_valid(form)