mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improved naming of new setting and variables
This commit is contained in:
parent
2bdd1305ed
commit
de1dfdcc38
@ -139,9 +139,9 @@ class InvenTreeSetting(models.Model):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
'STOCK_OWNER': {
|
'STOCK_OWNERSHIP_CONTROL': {
|
||||||
'name': _('Stock Owner Changes'),
|
'name': _('Stock Ownership Control'),
|
||||||
'description': _('Allow only owner of stock location and item to make changes'),
|
'description': _('Enable ownership control over stock locations and items'),
|
||||||
'default': False,
|
'default': False,
|
||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
|
|
||||||
{% include "stock/tabs.html" with tab="tracking" %}
|
{% include "stock/tabs.html" with tab="tracking" %}
|
||||||
|
|
||||||
{% setting_object 'STOCK_OWNER' as owner_enable %}
|
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
|
||||||
|
|
||||||
<h4>{% trans "Stock Tracking Information" %}</h4>
|
<h4>{% trans "Stock Tracking Information" %}</h4>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<!-- Check permissions and owner -->
|
<!-- Check permissions and owner -->
|
||||||
{% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user %}
|
{% if owner_control.value == "False" or owner_control.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'>
|
||||||
|
@ -15,7 +15,7 @@ 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 %}
|
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
|
||||||
|
|
||||||
{% if item.is_building %}
|
{% if item.is_building %}
|
||||||
<div class='alert alert-block alert-info'>
|
<div class='alert alert-block alert-info'>
|
||||||
@ -31,7 +31,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if owner_enable.value == "True" and not item.owner == user and not user.is_superuser %}
|
{% if owner_control.value == "True" and not item.owner == user and not user.is_superuser %}
|
||||||
<div class='alert alert-block alert-info'>
|
<div class='alert alert-block alert-info'>
|
||||||
{% trans "You are not the owner of this item. This stock item cannot be edited." %}<br>
|
{% trans "You are not the owner of this item. This stock item cannot be edited." %}<br>
|
||||||
</div>
|
</div>
|
||||||
@ -77,7 +77,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
|
|||||||
|
|
||||||
{% block page_data %}
|
{% block page_data %}
|
||||||
|
|
||||||
{% setting_object 'STOCK_OWNER' as owner_enable %}
|
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
|
||||||
|
|
||||||
<h3>
|
<h3>
|
||||||
{% trans "Stock Item" %}
|
{% trans "Stock Item" %}
|
||||||
@ -124,7 +124,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
|
|||||||
</div>
|
</div>
|
||||||
<!-- Stock adjustment menu -->
|
<!-- Stock adjustment menu -->
|
||||||
<!-- Check permissions and owner -->
|
<!-- Check permissions and owner -->
|
||||||
{% if owner_enable.value == "False" or owner_enable.value == "True" and item.owner == user or user.is_superuser %}
|
{% if owner_control.value == "False" or owner_control.value == "True" and item.owner == user or user.is_superuser %}
|
||||||
{% 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>
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% setting_object 'STOCK_OWNER' as owner_enable %}
|
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
|
||||||
|
|
||||||
{% if location and owner_enable.value == "True" and not location.owner in user.groups.all and not user.is_superuser %}
|
{% if location and owner_control.value == "True" and not location.owner in user.groups.all and not user.is_superuser %}
|
||||||
<div class='alert alert-block alert-info'>
|
<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>
|
{% trans "You are not in the list of owners of this location. This stock location cannot be edited." %}<br>
|
||||||
</div>
|
</div>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<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 owner_control.value == "False" or owner_control.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'/>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!-- Check permissions and owner -->
|
<!-- 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 owner_control.value == "False" or owner_control.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>
|
||||||
|
@ -146,8 +146,8 @@ class StockLocationEdit(AjaxUpdateView):
|
|||||||
form.fields['owner'].initial = location.parent.owner
|
form.fields['owner'].initial = location.parent.owner
|
||||||
|
|
||||||
# Disable selection if stock ownership control is enabled
|
# Disable selection if stock ownership control is enabled
|
||||||
stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER')
|
stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||||
if stock_owner_setting_enable:
|
if stock_ownership_control:
|
||||||
form.fields['owner'].disabled = True
|
form.fields['owner'].disabled = True
|
||||||
|
|
||||||
return form
|
return form
|
||||||
@ -159,8 +159,8 @@ class StockLocationEdit(AjaxUpdateView):
|
|||||||
|
|
||||||
self.object = form.save()
|
self.object = form.save()
|
||||||
|
|
||||||
stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER')
|
stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||||
if self.object.get_children() and stock_owner_setting_enable:
|
if self.object.get_children() and stock_ownership_control:
|
||||||
for child in self.object.get_children():
|
for child in self.object.get_children():
|
||||||
child.owner = self.object.owner
|
child.owner = self.object.owner
|
||||||
child.save()
|
child.save()
|
||||||
@ -1330,8 +1330,8 @@ class StockItemEdit(AjaxUpdateView):
|
|||||||
location = item.location
|
location = item.location
|
||||||
|
|
||||||
# Is ownership control enabled?
|
# Is ownership control enabled?
|
||||||
stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER')
|
stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||||
if stock_owner_setting_enable and location:
|
if stock_ownership_control and location:
|
||||||
# Check if location has owner
|
# Check if location has owner
|
||||||
if location.owner:
|
if location.owner:
|
||||||
form.fields['owner'].queryset = User.objects.filter(groups=location.owner)
|
form.fields['owner'].queryset = User.objects.filter(groups=location.owner)
|
||||||
@ -1344,9 +1344,9 @@ class StockItemEdit(AjaxUpdateView):
|
|||||||
owner = form.cleaned_data.get('owner', None)
|
owner = form.cleaned_data.get('owner', None)
|
||||||
|
|
||||||
# Is ownership control enabled?
|
# Is ownership control enabled?
|
||||||
stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER')
|
stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||||
|
|
||||||
if not owner and stock_owner_setting_enable:
|
if not owner and stock_ownership_control:
|
||||||
form.add_error('owner', _('Owner is required (ownership control is enabled)'))
|
form.add_error('owner', _('Owner is required (ownership control is enabled)'))
|
||||||
|
|
||||||
|
|
||||||
@ -1415,8 +1415,8 @@ class StockLocationCreate(AjaxCreateView):
|
|||||||
form.fields['owner'].initial = parent.owner
|
form.fields['owner'].initial = parent.owner
|
||||||
|
|
||||||
# Disable selection if stock ownership control is enabled
|
# Disable selection if stock ownership control is enabled
|
||||||
stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER')
|
stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||||
if stock_owner_setting_enable:
|
if stock_ownership_control:
|
||||||
form.fields['owner'].disabled = True
|
form.fields['owner'].disabled = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@ -1632,8 +1632,8 @@ class StockItemCreate(AjaxCreateView):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Is ownership control enabled?
|
# Is ownership control enabled?
|
||||||
stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER')
|
stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||||
if stock_owner_setting_enable and location:
|
if stock_ownership_control and location:
|
||||||
# Check if location has owner
|
# Check if location has owner
|
||||||
if location.owner:
|
if location.owner:
|
||||||
queryset = User.objects.filter(groups=location.owner)
|
queryset = User.objects.filter(groups=location.owner)
|
||||||
@ -1752,9 +1752,9 @@ class StockItemCreate(AjaxCreateView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Is ownership control enabled?
|
# Is ownership control enabled?
|
||||||
stock_owner_setting_enable = InvenTreeSetting.get_setting('STOCK_OWNER')
|
stock_ownership_control = InvenTreeSetting.get_setting('STOCK_OWNERSHIP_CONTROL')
|
||||||
|
|
||||||
if stock_owner_setting_enable:
|
if stock_ownership_control:
|
||||||
# Check if owner is set
|
# Check if owner is set
|
||||||
if not owner:
|
if not owner:
|
||||||
form.add_error('owner', _('Owner is required (ownership control is enabled)'))
|
form.add_error('owner', _('Owner is required (ownership control is enabled)'))
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<table class='table table-striped table-condensed'>
|
<table class='table table-striped table-condensed'>
|
||||||
<thead></thead>
|
<thead></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNER" %}
|
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
{% setting_object 'STOCK_OWNER' as owner_enable %}
|
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
|
||||||
|
|
||||||
<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;'>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
{% if read_only %}
|
{% if read_only %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<!-- Check permissions and owner -->
|
<!-- 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 owner_control.value == "False" or owner_control.value == "True" and location.owner in user.groups.all or user.is_superuser %}
|
||||||
{% 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" %}
|
||||||
|
Loading…
Reference in New Issue
Block a user