mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
ea2309793e
20
InvenTree/build/migrations/0024_auto_20201201_1023.py
Normal file
20
InvenTree/build/migrations/0024_auto_20201201_1023.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-11-30 23:23
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
import django.db.models.deletion
|
||||||
|
import mptt.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('build', '0023_auto_20201110_0911'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='build',
|
||||||
|
name='parent',
|
||||||
|
field=mptt.fields.TreeForeignKey(blank=True, help_text='BuildOrder to which this build is allocated', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='children', to='build.Build', verbose_name='Parent Build'),
|
||||||
|
),
|
||||||
|
]
|
@ -83,9 +83,10 @@ class Build(MPTTModel):
|
|||||||
help_text=_('Brief description of the build')
|
help_text=_('Brief description of the build')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO - Perhaps delete the build "tree"
|
||||||
parent = TreeForeignKey(
|
parent = TreeForeignKey(
|
||||||
'self',
|
'self',
|
||||||
on_delete=models.DO_NOTHING,
|
on_delete=models.SET_NULL,
|
||||||
blank=True, null=True,
|
blank=True, null=True,
|
||||||
related_name='children',
|
related_name='children',
|
||||||
verbose_name=_('Parent Build'),
|
verbose_name=_('Parent Build'),
|
||||||
|
@ -3,3 +3,6 @@ import multiprocessing
|
|||||||
bind = "0.0.0.0:8000"
|
bind = "0.0.0.0:8000"
|
||||||
|
|
||||||
workers = multiprocessing.cpu_count() * 2 + 1
|
workers = multiprocessing.cpu_count() * 2 + 1
|
||||||
|
|
||||||
|
max_requests = 1000
|
||||||
|
max_requests_jitter = 50
|
||||||
|
@ -99,7 +99,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if location and location.children.all|length > 0 %}
|
{% if location and location.children.all|length > 0 %}
|
||||||
{% include 'stock/location_list.html' with children=location.children.all collapse_id="locations" %}
|
{% include 'stock/location_list.html' with children=location.children.all collapse_id="locations" %}
|
||||||
@ -110,6 +109,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{% include "stock_table.html" %}
|
{% include "stock_table.html" %}
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -1292,6 +1292,7 @@ class StockItemEdit(AjaxUpdateView):
|
|||||||
# If the part cannot be purchased, hide the supplier_part field
|
# If the part cannot be purchased, hide the supplier_part field
|
||||||
if not item.part.purchaseable:
|
if not item.part.purchaseable:
|
||||||
form.fields['supplier_part'].widget = HiddenInput()
|
form.fields['supplier_part'].widget = HiddenInput()
|
||||||
|
form.fields['purchase_price'].widget = HiddenInput()
|
||||||
else:
|
else:
|
||||||
query = form.fields['supplier_part'].queryset
|
query = form.fields['supplier_part'].queryset
|
||||||
query = query.filter(part=item.part.id)
|
query = query.filter(part=item.part.id)
|
||||||
@ -1505,6 +1506,9 @@ class StockItemCreate(AjaxCreateView):
|
|||||||
|
|
||||||
form.rebuild_layout()
|
form.rebuild_layout()
|
||||||
|
|
||||||
|
if not part.purchaseable:
|
||||||
|
form.fields['purchase_price'].widget = HiddenInput()
|
||||||
|
|
||||||
# Hide the 'part' field (as a valid part is selected)
|
# Hide the 'part' field (as a valid part is selected)
|
||||||
# form.fields['part'].widget = HiddenInput()
|
# form.fields['part'].widget = HiddenInput()
|
||||||
|
|
||||||
|
@ -87,6 +87,64 @@ class RoleGroupAdmin(admin.ModelAdmin):
|
|||||||
RuleSetInline,
|
RuleSetInline,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
list_display = ('name', 'admin', 'part', 'stock', 'build', 'purchase_order', 'sales_order')
|
||||||
|
|
||||||
|
def get_rule_set(self, obj, rule_set_type):
|
||||||
|
''' Return list of permissions for the given ruleset '''
|
||||||
|
|
||||||
|
# Get all rulesets associated to object
|
||||||
|
rule_sets = RuleSet.objects.filter(group=obj.pk)
|
||||||
|
|
||||||
|
# Select ruleset based on type
|
||||||
|
for rule_set in rule_sets:
|
||||||
|
if rule_set.name == rule_set_type:
|
||||||
|
break
|
||||||
|
|
||||||
|
def append_permission_level(permission_level, next_level):
|
||||||
|
if not permission_level:
|
||||||
|
return next_level
|
||||||
|
|
||||||
|
if permission_level[:-1].endswith('|'):
|
||||||
|
permission_level += next_level
|
||||||
|
else:
|
||||||
|
permission_level += ' | ' + next_level
|
||||||
|
|
||||||
|
return permission_level
|
||||||
|
|
||||||
|
permission_level = ''
|
||||||
|
|
||||||
|
if rule_set.can_view:
|
||||||
|
permission_level = append_permission_level(permission_level, 'V')
|
||||||
|
|
||||||
|
if rule_set.can_add:
|
||||||
|
permission_level = append_permission_level(permission_level, 'A')
|
||||||
|
|
||||||
|
if rule_set.can_change:
|
||||||
|
permission_level = append_permission_level(permission_level, 'C')
|
||||||
|
|
||||||
|
if rule_set.can_delete:
|
||||||
|
permission_level = append_permission_level(permission_level, 'D')
|
||||||
|
|
||||||
|
return permission_level
|
||||||
|
|
||||||
|
def admin(self, obj):
|
||||||
|
return self.get_rule_set(obj, 'admin')
|
||||||
|
|
||||||
|
def part(self, obj):
|
||||||
|
return self.get_rule_set(obj, 'part')
|
||||||
|
|
||||||
|
def stock(self, obj):
|
||||||
|
return self.get_rule_set(obj, 'stock')
|
||||||
|
|
||||||
|
def build(self, obj):
|
||||||
|
return self.get_rule_set(obj, 'build')
|
||||||
|
|
||||||
|
def purchase_order(self, obj):
|
||||||
|
return self.get_rule_set(obj, 'purchase_order')
|
||||||
|
|
||||||
|
def sales_order(self, obj):
|
||||||
|
return self.get_rule_set(obj, 'sales_order')
|
||||||
|
|
||||||
def get_formsets_with_inlines(self, request, obj=None):
|
def get_formsets_with_inlines(self, request, obj=None):
|
||||||
for inline in self.get_inline_instances(request, obj):
|
for inline in self.get_inline_instances(request, obj):
|
||||||
# Hide RuleSetInline in the 'Add role' view
|
# Hide RuleSetInline in the 'Add role' view
|
||||||
|
Loading…
Reference in New Issue
Block a user