mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 19:15:41 +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:
@ -15,6 +15,11 @@ class EditStockLocationForm(forms.ModelForm):
|
||||
|
||||
self.helper.form_tag = False
|
||||
|
||||
initial = kwargs.get('initial', {})
|
||||
|
||||
if 'location' in initial:
|
||||
self.fields['parent'].disabled = True
|
||||
|
||||
class Meta:
|
||||
model = StockLocation
|
||||
fields = [
|
||||
@ -32,6 +37,12 @@ class EditStockItemForm(forms.ModelForm):
|
||||
|
||||
self.helper.form_tag = False
|
||||
|
||||
initial = kwargs.get('initial', {})
|
||||
|
||||
for field in ['part', 'location']:
|
||||
if field in initial:
|
||||
self.fields[field].disabled = True
|
||||
|
||||
class Meta:
|
||||
model = StockItem
|
||||
fields = [
|
||||
|
Reference in New Issue
Block a user