From fefa6ca5e2d8eb8317834bce14c4bf2b4664db2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Tue, 30 Aug 2016 17:16:00 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20d'un=20inventaire=20avec=20stoc?= =?UTF-8?q?k=20initial=20lors=20de=20la=20cr=C3=A9ation=20d'un=20article?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kfet/views.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kfet/views.py b/kfet/views.py index 7169c392..f869509d 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -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)