Added global setting and updated stock item templates

This commit is contained in:
eeintech 2020-12-01 15:54:05 -05:00
parent e1fb7e5d98
commit 2c38be2d13
5 changed files with 26 additions and 4 deletions

View File

@ -139,6 +139,13 @@ class InvenTreeSetting(models.Model):
'validator': bool, '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': { 'BUILDORDER_REFERENCE_PREFIX': {
'name': _('Build Order Reference Prefix'), 'name': _('Build Order Reference Prefix'),
'description': _('Prefix value for build order reference'), 'description': _('Prefix value for build order reference'),

View File

@ -11,7 +11,9 @@
<h4>{% trans "Stock Tracking Information" %}</h4> <h4>{% trans "Stock Tracking Information" %}</h4>
<hr> <hr>
{% if roles.stock.change %} <!-- Check permissions and owner -->
{% setting_object 'STOCK_OWNER' as owner_enable %}
{% if user.is_superuser or roles.stock.change and item.owner == user and owner_enable.value == "True" %}
<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'>

View File

@ -112,7 +112,10 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
</ul> </ul>
</div> </div>
<!-- Stock adjustment menu --> <!-- Stock adjustment menu -->
{% if roles.stock.change and not item.is_building %} <!-- Check permissions and owner -->
{% 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 %}
<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>
<ul class='dropdown-menu' role='menu'> <ul class='dropdown-menu' role='menu'>
@ -161,6 +164,8 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
<!-- Check permissions and owner -->
{% endif %}
<button type='button' class='btn btn-default' id='stock-test-report' title='{% trans "Generate test report" %}'> <button type='button' class='btn btn-default' id='stock-test-report' title='{% trans "Generate test report" %}'>
<span class='fas fa-file-invoice'/> <span class='fas fa-file-invoice'/>
</button> </button>

View File

@ -10,4 +10,14 @@
{% endblock %} {% endblock %}
{% block settings %} {% block settings %}
<h4>{% trans "Stock Options" %}</h4>
<table class='table table-striped table-condensed'>
<thead></thead>
<tbody>
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNER" %}
</tbody>
</table>
{% endblock %} {% endblock %}

View File

@ -1,6 +1,5 @@
{% load i18n %} {% load i18n %}
{% if roles.stock.change %}
<div id='attachment-buttons'> <div id='attachment-buttons'>
<div class='btn-group'> <div class='btn-group'>
<button type='button' class='btn btn-success' id='new-attachment'> <button type='button' class='btn btn-success' id='new-attachment'>
@ -8,7 +7,6 @@
</button> </button>
</div> </div>
</div> </div>
{% endif %}
<div class='dropzone' id='attachment-dropzone'> <div class='dropzone' id='attachment-dropzone'>
<table class='table table-striped table-condensed' data-toolbar='#attachment-buttons' id='attachment-table'> <table class='table table-striped table-condensed' data-toolbar='#attachment-buttons' id='attachment-table'>