From 6c5b09efd42fc5944ad04be3be5abc9e5dac354b Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@gmail.com>
Date: Wed, 28 Aug 2019 21:50:44 +1000
Subject: [PATCH] Provide initial data

---
 InvenTree/stock/views.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py
index 3c056dc73a..5b1f64192f 100644
--- a/InvenTree/stock/views.py
+++ b/InvenTree/stock/views.py
@@ -462,13 +462,25 @@ class StockLocationCreate(AjaxCreateView):
         return initials
 
 
-class StockItemSerialize(AjaxView, FormMixin):
+class StockItemSerialize(AjaxUpdateView):
     """ View for manually serializing a StockItem """
 
+    model = StockItem
     ajax_template_name = 'stock/item_serialize.html'
     ajax_form_title = 'Serialize Stock'
     form_class = SerializeStockForm
 
+    def get_initial(self):
+
+        initials = super().get_initial().copy()
+
+        item = self.get_object()
+
+        initials['quantity'] = item.quantity
+        initials['destination'] = item.location.pk
+
+        return initials
+
     def get(self, request, *args, **kwargs):
         
         return super().get(request, *args, **kwargs)