diff --git a/InvenTree/InvenTree/api_version.py b/InvenTree/InvenTree/api_version.py index c1defa567b..203aa09713 100644 --- a/InvenTree/InvenTree/api_version.py +++ b/InvenTree/InvenTree/api_version.py @@ -2,11 +2,14 @@ # InvenTree API version -INVENTREE_API_VERSION = 96 +INVENTREE_API_VERSION = 97 """ Increment this API version number whenever there is a significant change to the API that any clients need to know about +v97 -> 2023-02-20 : https://github.com/inventree/InvenTree/pull/4377 + - Adds "external" attribute to StockLocation model + v96 -> 2023-02-16 : https://github.com/inventree/InvenTree/pull/4345 - Adds stocktake report generation functionality diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 29177eab0b..88df0a541e 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -310,7 +310,8 @@ class StockLocationList(APIDownloadMixin, ListCreateAPI): filterset_fields = [ 'name', - 'structural' + 'structural', + 'external', ] search_fields = [ diff --git a/InvenTree/stock/migrations/0095_stocklocation_external.py b/InvenTree/stock/migrations/0095_stocklocation_external.py new file mode 100644 index 0000000000..3163f4aa17 --- /dev/null +++ b/InvenTree/stock/migrations/0095_stocklocation_external.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.18 on 2023-02-20 12:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0094_auto_20230220_0025'), + ] + + operations = [ + migrations.AddField( + model_name='stocklocation', + name='external', + field=models.BooleanField(default=False, help_text='This is an external stock location', verbose_name='External'), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 582151b17f..77928b3fee 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -122,6 +122,12 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree): 'but may be located to child locations.'), ) + external = models.BooleanField( + default=False, + verbose_name=_('External'), + help_text=_('This is an external stock location') + ) + def get_location_owner(self): """Get the closest "owner" for this location. diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 99b0866792..7336a1d15c 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -584,6 +584,7 @@ class LocationSerializer(InvenTree.serializers.InvenTreeModelSerializer): 'owner', 'icon', 'structural', + 'external', ] read_only_fields = [ diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index db0bb68530..356b000463 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -117,6 +117,7 @@ function stockLocationFields(options={}) { description: {}, owner: {}, structural: {}, + external: {}, icon: { help_text: `{% trans "Icon (optional) - Explore all available icons on" %} Font Awesome.`, placeholder: 'fas fa-box', @@ -2491,6 +2492,24 @@ function loadStockLocationTable(table, options) { title: '{% trans "Stock Items" %}', switchable: true, sortable: true, + }, + { + field: 'structural', + title: '{% trans "Structural" %}', + switchable: true, + sortable: false, + formatter: function(value) { + return yesNoLabel(value); + } + }, + { + field: 'external', + title: '{% trans "External" %}', + switchable: true, + sortable: false, + formatter: function(value) { + return yesNoLabel(value); + } } ] }); diff --git a/InvenTree/templates/js/translated/table_filters.js b/InvenTree/templates/js/translated/table_filters.js index 5035c7178e..6eb1b35791 100644 --- a/InvenTree/templates/js/translated/table_filters.js +++ b/InvenTree/templates/js/translated/table_filters.js @@ -134,6 +134,10 @@ function getAvailableTableFilters(tableKey) { type: 'bool', title: '{% trans "Structural" %}', }, + external: { + type: 'bool', + title: '{% trans "External" %}', + }, }; }