[FR] Add "priority" field to BuildOrder (#4225)

* [FR] Add "priority" field to BuildOrder
Fixes #3059

* Add priority to the frontend

* add field to serializer

* bump version
This commit is contained in:
Matthias Mair 2023-01-24 23:37:05 +01:00 committed by GitHub
parent 61e5244789
commit 428e939b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 1 deletions

View File

@ -2,10 +2,12 @@
# InvenTree API version
INVENTREE_API_VERSION = 87
INVENTREE_API_VERSION = 88
"""
Increment this API version number whenever there is a significant change to the API that any clients need to know about
v88 -> 2023-01-17: https://github.com/inventree/InvenTree/pull/4225
- Adds 'priority' field to Build model and api endpoints
v87 -> 2023-01-04 : https://github.com/inventree/InvenTree/pull/4067
- Add API date filter for stock table on Expiry date

View File

@ -101,6 +101,7 @@ class BuildList(APIDownloadMixin, ListCreateAPI):
'completed',
'issued_by',
'responsible',
'priority',
]
ordering_field_aliases = {
@ -115,6 +116,7 @@ class BuildList(APIDownloadMixin, ListCreateAPI):
'part__name',
'part__IPN',
'part__description',
'priority',
]
def get_queryset(self):

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.16 on 2023-01-17 20:37
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('build', '0036_auto_20220707_1101'),
]
operations = [
migrations.AddField(
model_name='build',
name='priority',
field=models.PositiveIntegerField(default=0, help_text='Priority of this build order', validators=[django.core.validators.MinValueValidator(0)], verbose_name='Build Priority'),
),
]

View File

@ -61,6 +61,7 @@ class Build(MPTTModel, ReferenceIndexingMixin):
completed_by: User that completed the build
issued_by: User that issued the build
responsible: User (or group) responsible for completing the build
priority: Priority of the build
"""
OVERDUE_FILTER = Q(status__in=BuildStatus.ACTIVE_CODES) & ~Q(target_date=None) & Q(target_date__lte=datetime.now().date())
@ -294,6 +295,13 @@ class Build(MPTTModel, ReferenceIndexingMixin):
help_text=_('Extra build notes')
)
priority = models.PositiveIntegerField(
verbose_name=_('Build Priority'),
default=0,
validators=[MinValueValidator(0)],
help_text=_('Priority of this build order')
)
def sub_builds(self, cascade=True):
"""Return all Build Order objects under this one."""
if cascade:

View File

@ -112,6 +112,7 @@ class BuildSerializer(InvenTreeModelSerializer):
'issued_by_detail',
'responsible',
'responsible_detail',
'priority',
]
read_only_fields = [

View File

@ -194,6 +194,13 @@ src="{% static 'img/blank_image.png' %}"
<td>{{ build.responsible }}</td>
</tr>
{% endif %}
{% if build.priority != 0 %}
<tr>
<td><span class="fa-solid fa-arrow-up-9-1"></span></td>
<td>{% trans "Priority" %}</td>
<td>{{ build.priority }}</td>
</tr>
{% endif %}
</table>
{% endblock %}

View File

@ -88,6 +88,13 @@
<td><a href="{% url 'build-detail' build.parent.id %}">{{ build.parent }}</a>{% include "clip.html"%}</td>
</tr>
{% endif %}
{% if build.priority != 0 %}
<tr>
<td><span class="fa-solid fa-arrow-up-9-1"></span></td>
<td>{% trans "Priority" %}</td>
<td>{{ build.priority }}</td>
</tr>
{% endif %}
{% if build.sales_order %}
<tr>
<td><span class='fas fa-dolly'></span></td>

View File

@ -46,6 +46,7 @@ function buildFormFields() {
},
title: {},
quantity: {},
priority: {},
parent: {
filters: {
part_detail: true,
@ -2596,6 +2597,12 @@ function loadBuildTable(table, options) {
title: '{% trans "Description" %}',
switchable: true,
},
{
field: 'priority',
title: '{% trans "Priority" %}',
switchable: true,
sortable: true,
},
{
field: 'part',
title: '{% trans "Part" %}',