diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 2f27dd602d..7441614ec5 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -139,6 +139,13 @@ class InvenTreeSetting(models.Model): 'validator': bool, }, + 'STOCK_OWNER': { + 'name': _('Stock Owner Changes'), + 'description': _('Allow only owner of stock location and item to make changes'), + 'default': False, + 'validator': bool, + }, + 'BUILDORDER_REFERENCE_PREFIX': { 'name': _('Build Order Reference Prefix'), 'description': _('Prefix value for build order reference'), diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 8f8502af2a..f9cbf472bc 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -11,7 +11,9 @@

{% trans "Stock Tracking Information" %}


-{% if roles.stock.change %} + +{% setting_object 'STOCK_OWNER' as owner_enable %} +{% if user.is_superuser or roles.stock.change and item.owner == user and owner_enable.value == "True" %}
- {% if roles.stock.change and not item.is_building %} + + {% setting_object 'STOCK_OWNER' as owner_enable %} + {% if user.is_superuser or roles.stock.change and item.owner == user and owner_enable.value == "True" %} + {% if not item.is_building %}
{% endif %} + + {% endif %} diff --git a/InvenTree/templates/InvenTree/settings/stock.html b/InvenTree/templates/InvenTree/settings/stock.html index c3c40087ff..f80a1c0926 100644 --- a/InvenTree/templates/InvenTree/settings/stock.html +++ b/InvenTree/templates/InvenTree/settings/stock.html @@ -10,4 +10,14 @@ {% endblock %} {% block settings %} + +

{% trans "Stock Options" %}

+ + + + + {% include "InvenTree/settings/setting.html" with key="STOCK_OWNER" %} + +
+ {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/attachment_table.html b/InvenTree/templates/attachment_table.html index d13b7b33b1..35b114cc05 100644 --- a/InvenTree/templates/attachment_table.html +++ b/InvenTree/templates/attachment_table.html @@ -1,6 +1,5 @@ {% load i18n %} -{% if roles.stock.change %}
-{% endif %}