keeping part id in inherited form

This commit is contained in:
Matthias 2021-05-06 16:45:39 +02:00
parent 4830ff28bf
commit 90c207b935

View File

@ -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