From 453254c2787d80d15876aed112bd5870ee2538db Mon Sep 17 00:00:00 2001 From: Lukas <76838159+wolflu05@users.noreply.github.com> Date: Wed, 17 Jul 2024 00:02:47 +0200 Subject: [PATCH] Add notes to mp and sp (#7667) * add notes to mp and sp * bump api version --- .../InvenTree/InvenTree/api_version.py | 5 +++- ...nufacturerpart_notes_supplierpart_notes.py | 24 +++++++++++++++ src/backend/InvenTree/company/models.py | 2 ++ src/backend/InvenTree/company/serializers.py | 6 ++-- .../templates/company/manufacturer_part.html | 29 +++++++++++++++++++ .../company/manufacturer_part_sidebar.html | 2 ++ .../templates/company/supplier_part.html | 29 +++++++++++++++++++ .../company/supplier_part_sidebar.html | 2 ++ .../pages/company/ManufacturerPartDetail.tsx | 14 +++++++++ .../src/pages/company/SupplierPartDetail.tsx | 14 +++++++++ 10 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/backend/InvenTree/company/migrations/0071_manufacturerpart_notes_supplierpart_notes.py diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index 6e436a5df0..91497f5ec7 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,12 +1,15 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 223 +INVENTREE_API_VERSION = 224 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v224 - 2024-07-14 : https://github.com/inventree/InvenTree/pull/7667 + - Add notes field to ManufacturerPart and SupplierPart API endpoints + v223 - 2024-07-14 : https://github.com/inventree/InvenTree/pull/7649 - Allow adjustment of "packaging" field when receiving items against a purchase order diff --git a/src/backend/InvenTree/company/migrations/0071_manufacturerpart_notes_supplierpart_notes.py b/src/backend/InvenTree/company/migrations/0071_manufacturerpart_notes_supplierpart_notes.py new file mode 100644 index 0000000000..b7d6c8caf7 --- /dev/null +++ b/src/backend/InvenTree/company/migrations/0071_manufacturerpart_notes_supplierpart_notes.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.11 on 2024-07-16 12:58 + +import InvenTree.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('company', '0070_remove_manufacturerpartattachment_manufacturer_part_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='manufacturerpart', + name='notes', + field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Markdown notes (optional)', max_length=50000, null=True, verbose_name='Notes'), + ), + migrations.AddField( + model_name='supplierpart', + name='notes', + field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Markdown notes (optional)', max_length=50000, null=True, verbose_name='Notes'), + ), + ] diff --git a/src/backend/InvenTree/company/models.py b/src/backend/InvenTree/company/models.py index 58b0938568..52eeb80cdc 100644 --- a/src/backend/InvenTree/company/models.py +++ b/src/backend/InvenTree/company/models.py @@ -451,6 +451,7 @@ class Address(InvenTree.models.InvenTreeModel): class ManufacturerPart( InvenTree.models.InvenTreeAttachmentMixin, InvenTree.models.InvenTreeBarcodeMixin, + InvenTree.models.InvenTreeNotesMixin, InvenTree.models.InvenTreeMetadataModel, ): """Represents a unique part as provided by a Manufacturer Each ManufacturerPart is identified by a MPN (Manufacturer Part Number) Each ManufacturerPart is also linked to a Part object. A Part may be available from multiple manufacturers. @@ -624,6 +625,7 @@ class SupplierPartManager(models.Manager): class SupplierPart( InvenTree.models.MetadataMixin, InvenTree.models.InvenTreeBarcodeMixin, + InvenTree.models.InvenTreeNotesMixin, common.models.MetaMixin, InvenTree.models.InvenTreeModel, ): diff --git a/src/backend/InvenTree/company/serializers.py b/src/backend/InvenTree/company/serializers.py index 68597d60a7..428ea7b5b8 100644 --- a/src/backend/InvenTree/company/serializers.py +++ b/src/backend/InvenTree/company/serializers.py @@ -213,7 +213,7 @@ class ContactSerializer(DataImportExportSerializerMixin, InvenTreeModelSerialize @register_importer() class ManufacturerPartSerializer( - DataImportExportSerializerMixin, InvenTreeTagModelSerializer + DataImportExportSerializerMixin, InvenTreeTagModelSerializer, NotesFieldMixin ): """Serializer for ManufacturerPart object.""" @@ -232,6 +232,7 @@ class ManufacturerPartSerializer( 'MPN', 'link', 'barcode_hash', + 'notes', 'tags', ] @@ -305,7 +306,7 @@ class ManufacturerPartParameterSerializer( @register_importer() class SupplierPartSerializer( - DataImportExportSerializerMixin, InvenTreeTagModelSerializer + DataImportExportSerializerMixin, InvenTreeTagModelSerializer, NotesFieldMixin ): """Serializer for SupplierPart object.""" @@ -340,6 +341,7 @@ class SupplierPartSerializer( 'supplier_detail', 'url', 'updated', + 'notes', 'tags', ] diff --git a/src/backend/InvenTree/company/templates/company/manufacturer_part.html b/src/backend/InvenTree/company/templates/company/manufacturer_part.html index a4676a9086..7d07fe282e 100644 --- a/src/backend/InvenTree/company/templates/company/manufacturer_part.html +++ b/src/backend/InvenTree/company/templates/company/manufacturer_part.html @@ -171,11 +171,40 @@ src="{% static 'img/blank_image.png' %}" +