diff --git a/InvenTree/InvenTree/metadata.py b/InvenTree/InvenTree/metadata.py index e7f78554f9..4294c943ba 100644 --- a/InvenTree/InvenTree/metadata.py +++ b/InvenTree/InvenTree/metadata.py @@ -98,7 +98,7 @@ class InvenTreeMetadata(SimpleMetadata): Override get_serializer_info so that we can add 'default' values to any fields whose Meta.model specifies a default value """ - + serializer_info = super().get_serializer_info(serializer) model_class = None @@ -108,6 +108,13 @@ class InvenTreeMetadata(SimpleMetadata): model_fields = model_meta.get_field_info(model_class) + model_default_func = getattr(model_class, 'api_defaults', None) + + if model_default_func: + model_default_values = model_class.api_defaults(self.request) + else: + model_default_values = {} + # Iterate through simple fields for name, field in model_fields.fields.items(): @@ -123,6 +130,9 @@ class InvenTreeMetadata(SimpleMetadata): serializer_info[name]['default'] = default + elif name in model_default_values: + serializer_info[name]['default'] = model_default_values[name] + # Iterate through relations for name, relation in model_fields.relations.items(): @@ -141,6 +151,9 @@ class InvenTreeMetadata(SimpleMetadata): if 'help_text' not in serializer_info[name] and hasattr(relation.model_field, 'help_text'): serializer_info[name]['help_text'] = relation.model_field.help_text + if name in model_default_values: + serializer_info[name]['default'] = model_default_values[name] + except AttributeError: pass diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 632ec2e0e5..cd9ce410de 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -34,8 +34,7 @@ } .login-header { - padding-right: 30px; - margin-right: 30px; + margin-right: 5px; } .login-container input { @@ -125,18 +124,16 @@ align-content: center; } -.qr-container { - width: 100%; - align-content: center; - object-fit: fill; -} - .navbar { border-bottom: 1px solid #ccc; background-color: var(--secondary-color); box-shadow: 0px 5px 5px rgb(0 0 0 / 5%); } +.inventree-navbar-menu { + position: absolute !important; +} + .navbar-brand { float: left; } @@ -545,6 +542,7 @@ .inventree-body { width: 100%; padding: 5px; + padding-right: 0; } .inventree-pre-content { @@ -835,7 +833,7 @@ input[type="submit"] { .panel { box-shadow: 2px 2px #DDD; - margin-bottom: 20px; + margin-bottom: .75rem; background-color: #fff; border: 1px solid #ccc; } diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 0dd6a404e5..4fe22f7e0e 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -47,7 +47,7 @@ def get_next_build_number(): """ if Build.objects.count() == 0: - return + return '0001' build = Build.objects.exclude(reference=None).last() @@ -100,13 +100,28 @@ class Build(MPTTModel, ReferenceIndexingMixin): return reverse('api-build-list') def api_instance_filters(self): - + return { 'parent': { 'exclude_tree': self.pk, } } + @classmethod + def api_defaults(cls, request): + """ + Return default values for this model when issuing an API OPTIONS request + """ + + defaults = { + 'reference': get_next_build_number(), + } + + if request and request.user: + defaults['issued_by'] = request.user.pk + + return defaults + def save(self, *args, **kwargs): self.rebuild_reference_field() diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 0c45e3746a..42106a7376 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -37,7 +37,7 @@ def get_next_po_number(): """ if PurchaseOrder.objects.count() == 0: - return + return '0001' order = PurchaseOrder.objects.exclude(reference=None).last() @@ -66,7 +66,7 @@ def get_next_so_number(): """ if SalesOrder.objects.count() == 0: - return + return '0001' order = SalesOrder.objects.exclude(reference=None).last() diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 23aea29dbd..3ab616d96d 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2050,10 +2050,10 @@ class Part(MPTTModel): if self.variant_of: parts.append(self.variant_of) - siblings = self.get_siblings(include_self=False) + siblings = self.get_siblings(include_self=False) - for sib in siblings: - parts.append(sib) + for sib in siblings: + parts.append(sib) filtered_parts = Part.objects.filter(pk__in=[part.pk for part in parts]) diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index f64c9b0704..0f8d81203a 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -53,6 +53,12 @@ + +{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %} +{% if owner_control.value == "True" %} + {% authorized_owners item.owner as owners %} +{% endif %} + {% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %} {% if roles.stock.change and not item.is_building %}