From 4830ff28bf88093607d7d8fe953669855c0f6bc0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 6 May 2021 16:34:37 +0200 Subject: [PATCH] new function for initials --- InvenTree/part/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index be33d07ee2..d157f7cf36 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -2051,6 +2051,10 @@ class PartPricing(AjaxView): return ctx + def get_initials(self): + """ returns initials for form """ + return {'quantity': self.get_quantity()} + def get(self, request, *args, **kwargs): quantity = self.get_quantity() @@ -2063,8 +2067,7 @@ class PartPricing(AjaxView): quantity = self.get_quantity() # Retain quantity value set by user - form = self.form_class() - form.fields['quantity'].initial = quantity + form = self.form_class(initial=self.get_initials()) # TODO - How to handle pricing in different currencies? currency = None