From 8dac6bb98248854690ca4ce56a19dd8b6842a59f Mon Sep 17 00:00:00 2001 From: eeintech Date: Tue, 1 Dec 2020 17:41:03 -0500 Subject: [PATCH] Updated template stock item logic and added to stock locations --- InvenTree/stock/templates/stock/item.html | 19 +++--- .../stock/templates/stock/item_base.html | 14 ++++- InvenTree/stock/templates/stock/location.html | 58 ++++++++++++------- InvenTree/templates/stock_table.html | 46 ++++++++------- 4 files changed, 84 insertions(+), 53 deletions(-) diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 51eae668f4..92c02e8a3b 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -8,21 +8,22 @@ {% include "stock/tabs.html" with tab="tracking" %} +{% setting_object 'STOCK_OWNER' as owner_enable %} +

{% trans "Stock Tracking Information" %}


-{% setting_object 'STOCK_OWNER' as owner_enable %} {% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user %} -{% if roles.stock.change and not item.is_building %} -
-
- + {% if roles.stock.change and not item.is_building %} +
+
+ +
-
-{% endif %} + {% endif %} {% endif %}
diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index c05a1c30df..a8d775ef1a 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -15,6 +15,8 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% block pre_content %} {% include 'stock/loc_link.html' with location=item.location %} +{% setting_object 'STOCK_OWNER' as owner_enable %} + {% if item.is_building %}
{% trans "This stock item is in production and cannot be edited." %}
@@ -29,6 +31,12 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% endif %} +{% if owner_enable.value == "True" and not item.owner == user and not user.is_superuser %} +
+ {% trans "You are not the owner of this item. This stock item cannot be edited." %}
+
+{% endif %} + {% if item.hasRequiredTests and not item.passedAllRequiredTests %}
{% trans "This stock item has not passed all required tests" %} @@ -68,6 +76,9 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% endblock %} {% block page_data %} + +{% setting_object 'STOCK_OWNER' as owner_enable %} +

{% trans "Stock Item" %} {% stock_status_label item.status large=True %} @@ -113,8 +124,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}

- {% setting_object 'STOCK_OWNER' as owner_enable %} - {% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user %} + {% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user or user.is_superuser %} {% if roles.stock.change and not item.is_building %}
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index fef3428373..d1fead76c3 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -1,8 +1,17 @@ {% extends "stock/stock_app_base.html" %} {% load static %} +{% load inventree_extras %} {% load i18n %} {% block content %} +{% setting_object 'STOCK_OWNER' as owner_enable %} + +{% if location and owner_enable.value == "True" and not location.owner in user.groups.all and not user.is_superuser %} +
+ {% trans "You are not in the list of owners of this location. This stock location cannot be edited." %}
+
+{% endif %} +
{% if location %} @@ -18,11 +27,13 @@

{% trans "All stock items" %}

{% endif %}
- {% if roles.stock.add %} - - {% endif %} + {% if owner_enable.value == "False" or owner_enable.value == "True" and location.owner in user.groups.all or user.is_superuser or not location %} + {% if roles.stock.add %} + + {% endif %} + {% endif %} {% if location %}
@@ -33,23 +44,26 @@
  • {% trans "Check-in Items" %}
  • - {% if roles.stock.change %} - -
    - - -
    + + {% if owner_enable.value == "False" or owner_enable.value == "True" and location.owner in user.groups.all or user.is_superuser %} + {% if roles.stock.change %} + +
    + + +
    + {% endif %} {% endif %} {% endif %}
    diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index 51f7c277db..fc5e7f506d 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -1,4 +1,7 @@ {% load i18n %} +{% load inventree_extras %} + +{% setting_object 'STOCK_OWNER' as owner_enable %}
    @@ -8,28 +11,31 @@ {% if read_only %} {% else %} - {% if roles.stock.add %} - - {% endif %} - {% if roles.stock.change or roles.stock.delete %} -
    - - -
    - {% endif %} + {% endif %} {% endif %}