2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-08 12:50:55 +00:00

Set initial value fields to disabled for some forms

- Prevent user from changing certain fields
- Only when a form is launched from a particular view
This commit is contained in:
Oliver
2018-04-28 12:14:18 +10:00
parent 2e7253ebc4
commit c1271367bd
5 changed files with 48 additions and 6 deletions

View File

@@ -13,6 +13,11 @@ class EditPartForm(forms.ModelForm):
self.helper.form_tag = False
initial = kwargs.get('initial', {})
if 'category' in initial:
self.fields['category'].disabled = True
class Meta:
model = Part
fields = [
@@ -40,6 +45,11 @@ class EditCategoryForm(forms.ModelForm):
self.helper.form_tag = False
initial = kwargs.get('initial', {})
if 'category' in initial:
self.fields['parent'].disabled = True
class Meta:
model = PartCategory
fields = [
@@ -59,6 +69,12 @@ class EditBomItemForm(forms.ModelForm):
self.helper.form_tag = False
initial = kwargs.get('initial', {})
for field in ['part', 'sub_part']:
if field in initial:
self.fields[field].disabled = True
class Meta:
model = BomItem
fields = [
@@ -75,6 +91,12 @@ class EditSupplierPartForm(forms.ModelForm):
self.helper.form_tag = False
initial = kwargs.get('initial', {})
for field in ['supplier', 'part']:
if field in initial:
self.fields[field].disabled = True
class Meta:
model = SupplierPart
fields = [