2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-15 00:38:12 +00:00

refactor(backend): port typo fixes from #10699 (#10926)

* typo fxes from #10699

* bump api version
This commit is contained in:
Matthias Mair
2025-11-28 20:03:02 +00:00
committed by GitHub
parent 3b6b702bd5
commit be5814112d
8 changed files with 22 additions and 19 deletions

View File

@@ -1,11 +1,14 @@
"""InvenTree API version information.""" """InvenTree API version information."""
# InvenTree API version # InvenTree API version
INVENTREE_API_VERSION = 427 INVENTREE_API_VERSION = 428
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" """Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """ INVENTREE_API_TEXT = """
v428 -> 2025-11-28 : https://github.com/inventree/InvenTree/pull/10926
- Various typo fixes in API - no functional changes
v427 -> 2025-11-24 : https://github.com/inventree/InvenTree/pull/10896 v427 -> 2025-11-24 : https://github.com/inventree/InvenTree/pull/10896
- Fixes a spelling mistake in the API field labels - Fixes a spelling mistake in the API field labels
@@ -42,7 +45,7 @@ v418 -> 2025-10-24 : https://github.com/inventree/InvenTree/pull/10657
v417 -> 2025-10-22 : https://github.com/inventree/InvenTree/pull/10654 v417 -> 2025-10-22 : https://github.com/inventree/InvenTree/pull/10654
- Adds "checked" filter to SalesOrderShipment API endpoint - Adds "checked" filter to SalesOrderShipment API endpoint
- Adds "order_status" filter to SalesOrdereShipment API endpoint - Adds "order_status" filter to SalesOrderShipment API endpoint
- Adds "order_outstanding" filter to SalesOrderShipment API endpoint - Adds "order_outstanding" filter to SalesOrderShipment API endpoint
v416 -> 2025-10-22 : https://github.com/inventree/InvenTree/pull/10651 v416 -> 2025-10-22 : https://github.com/inventree/InvenTree/pull/10651
@@ -100,7 +103,7 @@ v401 -> 2025-10-05 : https://github.com/inventree/InvenTree/pull/10381
- Adds machine properties to machine API endpoints - Adds machine properties to machine API endpoints
v400 -> 2025-10-05 : https://github.com/inventree/InvenTree/pull/10486 v400 -> 2025-10-05 : https://github.com/inventree/InvenTree/pull/10486
- Adds return datatypes for admin/config and flags entpoints - Adds return datatypes for admin/config and flags endpoints
v399 -> 2025-10-05 : https://github.com/inventree/InvenTree/pull/10445 v399 -> 2025-10-05 : https://github.com/inventree/InvenTree/pull/10445
- Refactors 'customer_detail' param in SalesOrder API endpoint - Refactors 'customer_detail' param in SalesOrder API endpoint

View File

@@ -69,7 +69,7 @@ def enable_filter(
Returns: Returns:
The decorated serializer field, marked as filterable. The decorated serializer field, marked as filterable.
""" """
# Ensure this function can be actually filteres # Ensure this function can be actually filtered
if not issubclass(func.__class__, FilterableSerializerField): if not issubclass(func.__class__, FilterableSerializerField):
raise TypeError( raise TypeError(
'INVE-I2: `enable_filter` can only be applied to serializer fields / serializers that contain the `FilterableSerializerField` mixin!' 'INVE-I2: `enable_filter` can only be applied to serializer fields / serializers that contain the `FilterableSerializerField` mixin!'
@@ -132,11 +132,11 @@ class FilterableSerializerMixin:
query_params = dict(getattr(context.get('request', {}), 'query_params', {})) query_params = dict(getattr(context.get('request', {}), 'query_params', {}))
# Remove filter args from kwargs to avoid issues with super().__init__ # Remove filter args from kwargs to avoid issues with super().__init__
poped_kwargs = {} # store popped kwargs as a arg might be reused for multiple fields popped_kwargs = {} # store popped kwargs as a arg might be reused for multiple fields
tgs_vals: dict[str, bool] = {} tgs_vals: dict[str, bool] = {}
for k, v in self.filter_targets.items(): for k, v in self.filter_targets.items():
pop_ref = v['filter_name'] or k pop_ref = v['filter_name'] or k
val = kwargs.pop(pop_ref, poped_kwargs.get(pop_ref)) val = kwargs.pop(pop_ref, popped_kwargs.get(pop_ref))
# Optionally also look in query parameters # Optionally also look in query parameters
if val is None and self.filter_on_query and v.get('filter_by_query', True): if val is None and self.filter_on_query and v.get('filter_by_query', True):
@@ -145,13 +145,13 @@ class FilterableSerializerMixin:
val = val[0] val = val[0]
if val: # Save popped value for reuse if val: # Save popped value for reuse
poped_kwargs[pop_ref] = val popped_kwargs[pop_ref] = val
tgs_vals[k] = ( tgs_vals[k] = (
str2bool(val) if isinstance(val, (str, int, float)) else val str2bool(val) if isinstance(val, (str, int, float)) else val
) # Support for various filtering style for backwards compatibility ) # Support for various filtering style for backwards compatibility
self.filter_target_values = tgs_vals self.filter_target_values = tgs_vals
# Ensure this mixin is not proadly applied as it is expensive on scale (total CI time increased by 21% when running all coverage tests) # Ensure this mixin is not broadly applied as it is expensive on scale (total CI time increased by 21% when running all coverage tests)
if len(self.filter_targets) == 0 and not self.no_filters: if len(self.filter_targets) == 0 and not self.no_filters:
raise Exception( raise Exception(
'INVE-I2: No filter targets found in fields, remove `PathScopedMixin`' 'INVE-I2: No filter targets found in fields, remove `PathScopedMixin`'

View File

@@ -85,7 +85,7 @@ class Build(
InvenTree.models.MetadataMixin, InvenTree.models.MetadataMixin,
InvenTree.models.InvenTreeTree, InvenTree.models.InvenTreeTree,
): ):
"""A Build object organises the creation of new StockItem objects from other existing StockItem objects. """A Build object organizes the creation of new StockItem objects from other existing StockItem objects.
Attributes: Attributes:
part: The part to be built (from component BOM items) part: The part to be built (from component BOM items)

View File

@@ -366,7 +366,7 @@ class SupplierPartMixin:
serializer_class = SupplierPartSerializer serializer_class = SupplierPartSerializer
def get_queryset(self, *args, **kwargs): def get_queryset(self, *args, **kwargs):
"""Return annotated queryest object for the SupplierPart list.""" """Return annotated queryset object for the SupplierPart list."""
queryset = super().get_queryset(*args, **kwargs) queryset = super().get_queryset(*args, **kwargs)
queryset = SupplierPartSerializer.annotate_queryset(queryset) queryset = SupplierPartSerializer.annotate_queryset(queryset)

View File

@@ -297,7 +297,7 @@ class Contact(InvenTree.models.InvenTreeMetadataModel):
@staticmethod @staticmethod
def get_api_url(): def get_api_url():
"""Return the API URL associated with the Contcat model.""" """Return the API URL associated with the Contact model."""
return reverse('api-contact-list') return reverse('api-contact-list')
company = models.ForeignKey( company = models.ForeignKey(
@@ -382,7 +382,7 @@ class Address(InvenTree.models.InvenTreeModel):
@staticmethod @staticmethod
def get_api_url(): def get_api_url():
"""Return the API URL associated with the Contcat model.""" """Return the API URL associated with the Contact model."""
return reverse('api-address-list') return reverse('api-address-list')
company = models.ForeignKey( company = models.ForeignKey(
@@ -888,7 +888,7 @@ class SupplierPart(
) )
def base_quantity(self, quantity=1) -> Decimal: def base_quantity(self, quantity=1) -> Decimal:
"""Calculate the base unit quantiy for a given quantity.""" """Calculate the base unit quantity for a given quantity."""
q = Decimal(quantity) * Decimal(self.pack_quantity_native) q = Decimal(quantity) * Decimal(self.pack_quantity_native)
q = round(q, 10).normalize() q = round(q, 10).normalize()

View File

@@ -1323,7 +1323,7 @@ class SalesOrderAllocationList(
class SalesOrderAllocationDetail(SalesOrderAllocationMixin, RetrieveUpdateDestroyAPI): class SalesOrderAllocationDetail(SalesOrderAllocationMixin, RetrieveUpdateDestroyAPI):
"""API endpoint for detali view of a SalesOrderAllocation object.""" """API endpoint for detail view of a SalesOrderAllocation object."""
class SalesOrderShipmentFilter(FilterSet): class SalesOrderShipmentFilter(FilterSet):
@@ -1374,7 +1374,7 @@ class SalesOrderShipmentFilter(FilterSet):
) )
def filter_order_status(self, queryset, name, value): def filter_order_status(self, queryset, name, value):
"""Filter by linked SalesOrderrder status.""" """Filter by linked SalesOrder status."""
q1 = Q(order__status=value, order__status_custom_key__isnull=True) q1 = Q(order__status=value, order__status_custom_key__isnull=True)
q2 = Q(order__status_custom_key=value) q2 = Q(order__status_custom_key=value)
@@ -1412,7 +1412,7 @@ class SalesOrderShipmentList(SalesOrderShipmentMixin, ListCreateAPI):
class SalesOrderShipmentDetail(SalesOrderShipmentMixin, RetrieveUpdateDestroyAPI): class SalesOrderShipmentDetail(SalesOrderShipmentMixin, RetrieveUpdateDestroyAPI):
"""API detail endpooint for SalesOrderShipment model.""" """API detail endpoint for SalesOrderShipment model."""
class SalesOrderShipmentComplete(CreateAPI): class SalesOrderShipmentComplete(CreateAPI):
@@ -1964,7 +1964,7 @@ order_api_urls = [
), ),
]), ]),
), ),
# API endpoints for sales ordesr # API endpoints for sales orders
path( path(
'so/', 'so/',
include([ include([

View File

@@ -988,7 +988,7 @@ class PurchaseOrder(TotalPriceMixin, Order):
# Before we continue, validate that each line item is valid # Before we continue, validate that each line item is valid
# We validate this here because it is far more efficient, # We validate this here because it is far more efficient,
# after we have fetched *all* line itemes in a single DB query # after we have fetched *all* line items in a single DB query
for line_item in line_item_map.values(): for line_item in line_item_map.values():
if line_item.order != self: if line_item.order != self:
raise ValidationError({_('Line item does not match purchase order')}) raise ValidationError({_('Line item does not match purchase order')})

View File

@@ -1027,7 +1027,7 @@ class Part(
self.ensure_trackable() self.ensure_trackable()
def ensure_trackable(self): def ensure_trackable(self):
"""Ensure that trackable is set correctly downline.""" """Ensure that trackable is set correctly downstream."""
if self.trackable: if self.trackable:
for part in self.get_used_in(): for part in self.get_used_in():
if not part.trackable: if not part.trackable: