2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-09 21:30:54 +00:00

Improvements for part creation API endpoint (#4281)

* Refactor javascript for creating a new part

* Simplify method of removing create fields from serializer

* Fix bug which resulted in multiple model instances being created

* remove custom code required on Part model

* Reorganize existing Part API test code

* Add child serializer for part duplication options

* Part duplication is now handled by the DRF serializer

- Improved validation options
- API is self-documenting (no more secret fields)
- More DRY

* Initial stock is now handled by the DRF serializer

* Adds child serializer for adding initial supplier data for a Part instance

* Create initial supplier and manufacturer parts as specified

* Adding unit tests

* Add unit tests for part duplication via API

* Bump API version

* Add javascript for automatically extracting info for nested fields

* Improvements for part creation form rendering

- Move to nested fields (using API metadata)
- Visual improvements
- Improve some field name / description values

* Properly format nested fields for sending to the server

* Handle error case for scrollIntoView

* Display errors for nested fields

* Fix bug for filling part category

* JS linting fixes

* Unit test fixes

* Fixes for unit tests

* Further fixes to unit tests
This commit is contained in:
Oliver
2023-02-02 09:24:16 +11:00
committed by GitHub
parent c6df0dbb2d
commit 4f029d4d81
15 changed files with 770 additions and 585 deletions

View File

@@ -46,3 +46,12 @@
name: Another manufacturer
description: They build things and sell it to us
is_manufacturer: True
- model: company.company
pk: 8
fields:
name: Customer only
description: Just a customer
is_customer: True
is_supplier: False
is_manufacturer: False

View File

@@ -94,17 +94,6 @@ class Company(MetadataMixin, models.Model):
]
verbose_name_plural = "Companies"
def __init__(self, *args, **kwargs):
"""Custom initialization routine for the Company model.
Ensures that custom serializer fields (without matching model fields) are removed
"""
# Remote image specified during creation via API
kwargs.pop('remote_image', None)
super().__init__(*args, **kwargs)
name = models.CharField(max_length=100, blank=False,
help_text=_('Company name'),
verbose_name=_('Company name'))