Updated template stock item logic and added to stock locations

This commit is contained in:
eeintech 2020-12-01 17:41:03 -05:00
parent 4104e7df8e
commit 8dac6bb982
4 changed files with 84 additions and 53 deletions

View File

@ -8,21 +8,22 @@
{% include "stock/tabs.html" with tab="tracking" %} {% include "stock/tabs.html" with tab="tracking" %}
{% setting_object 'STOCK_OWNER' as owner_enable %}
<h4>{% trans "Stock Tracking Information" %}</h4> <h4>{% trans "Stock Tracking Information" %}</h4>
<hr> <hr>
<!-- Check permissions and owner --> <!-- Check permissions and owner -->
{% 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 %}
{% if roles.stock.change and not item.is_building %} {% if roles.stock.change and not item.is_building %}
<div id='table-toolbar'> <div id='table-toolbar'>
<div class='btn-group'> <div class='btn-group'>
<button class='btn btn-success' type='button' title='New tracking entry' id='new-entry'> <button class='btn btn-success' type='button' title='New tracking entry' id='new-entry'>
<span class='fas fa-plus-circle'></span> {% trans "New Entry" %} <span class='fas fa-plus-circle'></span> {% trans "New Entry" %}
</button> </button>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
<table class='table table-condensed table-striped' id='track-table' data-toolbar='#table-toolbar'> <table class='table table-condensed table-striped' id='track-table' data-toolbar='#table-toolbar'>
</table> </table>

View File

@ -15,6 +15,8 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% block pre_content %} {% block pre_content %}
{% include 'stock/loc_link.html' with location=item.location %} {% include 'stock/loc_link.html' with location=item.location %}
{% setting_object 'STOCK_OWNER' as owner_enable %}
{% if item.is_building %} {% if item.is_building %}
<div class='alert alert-block alert-info'> <div class='alert alert-block alert-info'>
{% trans "This stock item is in production and cannot be edited." %}<br> {% trans "This stock item is in production and cannot be edited." %}<br>
@ -29,6 +31,12 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
</div> </div>
{% endif %} {% endif %}
{% if owner_enable.value == "True" and not item.owner == user and not user.is_superuser %}
<div class='alert alert-block alert-info'>
{% trans "You are not the owner of this item. This stock item cannot be edited." %}<br>
</div>
{% endif %}
{% if item.hasRequiredTests and not item.passedAllRequiredTests %} {% if item.hasRequiredTests and not item.passedAllRequiredTests %}
<div class='alert alert-block alert-danger'> <div class='alert alert-block alert-danger'>
{% trans "This stock item has not passed all required tests" %} {% trans "This stock item has not passed all required tests" %}
@ -68,6 +76,9 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% endblock %} {% endblock %}
{% block page_data %} {% block page_data %}
{% setting_object 'STOCK_OWNER' as owner_enable %}
<h3> <h3>
{% trans "Stock Item" %} {% trans "Stock Item" %}
{% stock_status_label item.status large=True %} {% stock_status_label item.status large=True %}
@ -113,8 +124,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
</div> </div>
<!-- Stock adjustment menu --> <!-- Stock adjustment menu -->
<!-- Check permissions and owner --> <!-- Check permissions and owner -->
{% setting_object 'STOCK_OWNER' as owner_enable %} {% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user or user.is_superuser %}
{% 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 %}
<div class='btn-group'> <div class='btn-group'>
<button id='stock-options' title='{% trans "Stock adjustment actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button> <button id='stock-options' title='{% trans "Stock adjustment actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button>

View File

@ -1,8 +1,17 @@
{% extends "stock/stock_app_base.html" %} {% extends "stock/stock_app_base.html" %}
{% load static %} {% load static %}
{% load inventree_extras %}
{% load i18n %} {% load i18n %}
{% block content %} {% 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 %}
<div class='alert alert-block alert-info'>
{% trans "You are not in the list of owners of this location. This stock location cannot be edited." %}<br>
</div>
{% endif %}
<div class='row'> <div class='row'>
<div class='col-sm-6'> <div class='col-sm-6'>
{% if location %} {% if location %}
@ -18,11 +27,13 @@
<p>{% trans "All stock items" %}</p> <p>{% trans "All stock items" %}</p>
{% endif %} {% endif %}
<div class='btn-group action-buttons' role='group'> <div class='btn-group action-buttons' role='group'>
{% 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 %} {% if roles.stock.add %}
<button class='btn btn-default' id='location-create' title='{% trans "Create new stock location" %}'> <button class='btn btn-default' id='location-create' title='{% trans "Create new stock location" %}'>
<span class='fas fa-plus-circle icon-green'/> <span class='fas fa-plus-circle icon-green'/>
</button> </button>
{% endif %} {% endif %}
{% endif %}
<!-- Barcode actions menu --> <!-- Barcode actions menu -->
{% if location %} {% if location %}
<div class='btn-group'> <div class='btn-group'>
@ -33,6 +44,8 @@
<li><a href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li> <li><a href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li>
</ul> </ul>
</div> </div>
<!-- Check permissions and owner -->
{% 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 %} {% if roles.stock.change %}
<div class='btn-group'> <div class='btn-group'>
<button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button> <button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button>
@ -52,6 +65,7 @@
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %}
</div> </div>
</div> </div>
<div class='col-sm-6'> <div class='col-sm-6'>

View File

@ -1,4 +1,7 @@
{% load i18n %} {% load i18n %}
{% load inventree_extras %}
{% setting_object 'STOCK_OWNER' as owner_enable %}
<div id='button-toolbar'> <div id='button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right;'> <div class='button-toolbar container-fluid' style='float: right;'>
@ -8,6 +11,8 @@
</button> </button>
{% if read_only %} {% if read_only %}
{% else %} {% else %}
<!-- Check permissions and owner -->
{% if owner_enable.value == "False" or owner_enable.value == "True" and location.owner in user.groups.all %}
{% if roles.stock.add %} {% if roles.stock.add %}
<button class="btn btn-success" id='item-create'> <button class="btn btn-success" id='item-create'>
<span class='fas fa-plus-circle'></span> {% trans "New Stock Item" %} <span class='fas fa-plus-circle'></span> {% trans "New Stock Item" %}
@ -31,6 +36,7 @@
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %}
</div> </div>
<div class='filter-list' id='filter-list-stock'> <div class='filter-list' id='filter-list-stock'>
<!-- An empty div in which the filter list will be constructed --> <!-- An empty div in which the filter list will be constructed -->