Add setting to disable IPN editing after part is created (web only)

This commit is contained in:
eeintech 2021-03-12 10:30:31 -05:00
parent ed028aed62
commit b152f7041b
3 changed files with 14 additions and 0 deletions

View File

@ -97,6 +97,13 @@ class InvenTreeSetting(models.Model):
'validator': bool,
},
'PART_ALLOW_EDIT_IPN': {
'name': _('Allow Editing IPN'),
'description': _('Allow changing the IPN value while editing a part'),
'default': True,
'validator': bool,
},
'PART_COPY_BOM': {
'name': _('Copy Part BOM Data'),
'description': _('Copy BOM data by default when duplicating a part'),

View File

@ -910,6 +910,12 @@ class PartEdit(AjaxUpdateView):
form.fields['default_supplier'].queryset = SupplierPart.objects.filter(part=part)
# Check if IPN can be edited
ipn_edit_enable = InvenTreeSetting.get_setting('PART_ALLOW_EDIT_IPN')
if not ipn_edit_enable and not self.request.user.is_superuser:
# Admin can still change IPN
form.fields['IPN'].disabled = True
return form

View File

@ -18,6 +18,7 @@
<tbody>
{% include "InvenTree/settings/setting.html" with key="PART_IPN_REGEX" %}
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_DUPLICATE_IPN" %}
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_EDIT_IPN" %}
{% include "InvenTree/settings/setting.html" with key="PART_SHOW_QUANTITY_IN_FORMS" icon="fa-hashtag" %}
{% include "InvenTree/settings/setting.html" with key="PART_RECENT_COUNT" icon="fa-clock" %}
<tr><td colspan='5 '></td></tr>