diff --git a/InvenTree/InvenTree/api_version.py b/InvenTree/InvenTree/api_version.py
index 203aa09713..29774af0d5 100644
--- a/InvenTree/InvenTree/api_version.py
+++ b/InvenTree/InvenTree/api_version.py
@@ -2,11 +2,14 @@
# InvenTree API version
-INVENTREE_API_VERSION = 97
+INVENTREE_API_VERSION = 98
"""
Increment this API version number whenever there is a significant change to the API that any clients need to know about
+v98 -> 2023-02-24 : https://github.com/inventree/InvenTree/pull/4408
+ - Adds "responsible" filter to Build API
+
v97 -> 2023-02-20 : https://github.com/inventree/InvenTree/pull/4377
- Adds "external" attribute to StockLocation model
diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py
index 9fda2c3065..dd52145ad0 100644
--- a/InvenTree/build/api.py
+++ b/InvenTree/build/api.py
@@ -2,6 +2,7 @@
from django.urls import include, re_path
from django.utils.translation import gettext_lazy as _
+from django.contrib.auth.models import User
from rest_framework import filters
from rest_framework.exceptions import ValidationError
@@ -65,6 +66,20 @@ class BuildFilter(rest_filters.FilterSet):
return queryset
+ assigned_to = rest_filters.NumberFilter(label='responsible', method='filter_responsible')
+
+ def filter_responsible(self, queryset, name, value):
+ """Filter by orders which are assigned to the specified owner."""
+ owners = list(Owner.objects.filter(pk=value))
+
+ # if we query by a user, also find all ownerships through group memberships
+ if len(owners) > 0 and owners[0].label() == 'user':
+ owners = Owner.get_owners_matching_user(User.objects.get(pk=owners[0].owner_id))
+
+ queryset = queryset.filter(responsible__in=owners)
+
+ return queryset
+
# Exact match for reference
reference = rest_filters.CharFilter(
label='Filter by exact reference',
diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js
index 4ccc44968c..fd9236994c 100644
--- a/InvenTree/templates/js/translated/build.js
+++ b/InvenTree/templates/js/translated/build.js
@@ -2695,11 +2695,19 @@ function loadBuildTable(table, options) {
title: '{% trans "Responsible" %}',
sortable: true,
formatter: function(value, row) {
- if (value) {
- return row.responsible_detail.name;
- } else {
+ if (!row.responsible_detail) {
return '-';
}
+
+ var html = row.responsible_detail.name;
+
+ if (row.responsible_detail.label == 'group') {
+ html += ``;
+ } else {
+ html += ``;
+ }
+
+ return html;
}
},
{
diff --git a/InvenTree/templates/js/translated/filters.js b/InvenTree/templates/js/translated/filters.js
index 78dd67043d..7a2d8687a2 100644
--- a/InvenTree/templates/js/translated/filters.js
+++ b/InvenTree/templates/js/translated/filters.js
@@ -241,6 +241,11 @@ function generateFilterInput(tableKey, filterKey) {
// Return a 'select' input with the available values
html = `