Project Responsible (#5944)

* Add "responsible owner" to project code table

* Update project code serializer

* Update CUI project code table

* Update PUI project code table

* Update API version
This commit is contained in:
Oliver 2023-11-21 23:13:20 +11:00 committed by GitHub
parent 6090ddfdf3
commit 2ccddd8f2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 6 deletions

View File

@ -2,11 +2,14 @@
# InvenTree API version
INVENTREE_API_VERSION = 153
INVENTREE_API_VERSION = 154
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v154 -> 2023-11-21 : https://github.com/inventree/InvenTree/pull/5944
- Adds "responsible" field to the ProjectCode table
v153 -> 2023-11-21 : https://github.com/inventree/InvenTree/pull/5956
- Adds override_min and override_max fields to part pricing API

View File

@ -0,0 +1,20 @@
# Generated by Django 3.2.23 on 2023-11-20 08:04
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0010_alter_apitoken_key'),
('common', '0021_auto_20230805_1748'),
]
operations = [
migrations.AddField(
model_name='projectcode',
name='responsible',
field=models.ForeignKey(blank=True, help_text='User or group responsible for this project', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='project_codes', to='users.owner', verbose_name='Responsible'),
),
]

View File

@ -51,6 +51,7 @@ import InvenTree.tasks
import InvenTree.validators
import order.validators
import report.helpers
import users.models
from plugin import registry
logger = logging.getLogger('inventree')
@ -126,6 +127,15 @@ class ProjectCode(InvenTree.models.MetadataMixin, models.Model):
help_text=_('Project description'),
)
responsible = models.ForeignKey(
users.models.Owner,
on_delete=models.SET_NULL,
blank=True, null=True,
verbose_name=_('Responsible'),
help_text=_('User or group responsible for this project'),
related_name='project_codes',
)
class SettingsKeyType(TypedDict, total=False):
"""Type definitions for a SettingsKeyType

View File

@ -11,6 +11,7 @@ from InvenTree.helpers import get_objectreference
from InvenTree.helpers_model import construct_absolute_url
from InvenTree.serializers import (InvenTreeImageSerializerField,
InvenTreeModelSerializer)
from users.serializers import OwnerSerializer
class SettingsValueField(serializers.Field):
@ -281,9 +282,13 @@ class ProjectCodeSerializer(InvenTreeModelSerializer):
fields = [
'pk',
'code',
'description'
'description',
'responsible',
'responsible_detail',
]
responsible_detail = OwnerSerializer(source='responsible', read_only=True)
class FlagSerializer(serializers.Serializer):
"""Serializer for feature flags."""

View File

@ -145,6 +145,25 @@ onPanelLoad('project-codes', function() {
sortable: true,
title: '{% trans "Project Code" %}',
},
{
field: 'responsible',
title: '{% trans "Responsible" %}',
formatter: function(value, row) {
if (!row.responsible_detail) {
return '-';
}
var html = row.responsible_detail.name;
if (row.responsible_detail.label == '{% trans "group" %}') {
html += `<span class='float-right fas fa-users'></span>`;
} else {
html += `<span class='float-right fas fa-user'></span>`;
}
return html;
}
},
{
field: 'description',
sortable: false,
@ -171,6 +190,7 @@ onPanelLoad('project-codes', function() {
fields: {
code: {},
description: {},
responsible: {},
},
refreshTable: '#project-code-table',
});

View File

@ -14,7 +14,7 @@ import { apiUrl } from '../../../states/ApiState';
import { useUserState } from '../../../states/UserState';
import { AddItemButton } from '../../buttons/AddItemButton';
import { TableColumn } from '../Column';
import { DescriptionColumn } from '../ColumnRenderers';
import { DescriptionColumn, ResponsibleColumn } from '../ColumnRenderers';
import { InvenTreeTable } from '../InvenTreeTable';
import { RowAction, RowDeleteAction, RowEditAction } from '../RowActions';
@ -33,7 +33,8 @@ export function ProjectCodeTable() {
sortable: true,
title: t`Project Code`
},
DescriptionColumn()
DescriptionColumn(),
ResponsibleColumn()
];
}, []);
@ -49,7 +50,8 @@ export function ProjectCodeTable() {
title: t`Edit project code`,
fields: {
code: {},
description: {}
description: {},
responsible: {}
},
onFormSuccess: refreshTable,
successMessage: t`Project code updated`
@ -82,7 +84,8 @@ export function ProjectCodeTable() {
title: t`Add project code`,
fields: {
code: {},
description: {}
description: {},
responsible: {}
},
onFormSuccess: refreshTable,
successMessage: t`Added project code`