Merge pull request #1139 from eeintech/fix_supplierpart_edit_form

Fix for SupplierPart edit form validation
This commit is contained in:
Oliver 2020-11-20 09:40:00 +11:00 committed by GitHub
commit a0168515c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -274,6 +274,12 @@ class SupplierPartEdit(AjaxUpdateView):
def get_form(self): def get_form(self):
form = super().get_form() form = super().get_form()
supplier_part = self.get_object()
# It appears that hiding a MoneyField fails validation
# Therefore the idea to set the value before hiding
if form.is_valid():
form.cleaned_data['single_pricing'] = supplier_part.unit_pricing
# Hide the single-pricing field (only for creating a new SupplierPart!) # Hide the single-pricing field (only for creating a new SupplierPart!)
form.fields['single_pricing'].widget = HiddenInput() form.fields['single_pricing'].widget = HiddenInput()