From 90c207b935db14cd93c446bcd507eb44cf8b2368 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 6 May 2021 16:45:39 +0200 Subject: [PATCH] keeping part id in inherited form --- InvenTree/order/views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py index e68ff91e83..37b758eb09 100644 --- a/InvenTree/order/views.py +++ b/InvenTree/order/views.py @@ -1577,6 +1577,11 @@ class SalesOrderAllocationDelete(AjaxDeleteView): class LineItemPricing(PartPricing): """ View for inspecting part pricing information """ + class EnhancedForm(PartPricing.form_class): + pk = IntegerField(widget = HiddenInput()) + + form_class = EnhancedForm + def get_part(self): if 'line_item' in self.request.GET: try: @@ -1584,6 +1589,12 @@ class LineItemPricing(PartPricing): return SalesOrderLineItem.objects.get(id=part_id).part except Part.DoesNotExist: return None + elif 'pk' in self.request.POST: + try: + part_id = self.request.POST.get('pk') + return Part.objects.get(id=part_id) + except Part.DoesNotExist: + return None else: return None @@ -1594,3 +1605,7 @@ class LineItemPricing(PartPricing): return Decimal(self.request.POST.get('quantity', 1)) return qty + def get_initials(self): + initials = super().get_initials() + initials['pk'] = self.get_part().id + return initials