Line number int (#11885)

* Add migration

Co-authored-by: Copilot <copilot@github.com>

* Update model on save

Co-authored-by: Copilot <copilot@github.com>

* Add API filter aliases

Co-authored-by: Copilot <copilot@github.com>

* Improved query for data migration

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Oliver
2026-05-07 22:48:47 +10:00
committed by GitHub
co-authored by Copilot
parent e16eb4a94d
commit 5c65cf901f
3 changed files with 94 additions and 3 deletions
+13
View File
@@ -1755,6 +1755,8 @@ class OrderLineItem(InvenTree.models.InvenTreeMetadataModel):
Attributes:
quantity: Number of items
line: The line number for this item (optional)
line_int: An integer line number for this item (optional - used for natural sorting)
reference: Reference text (e.g. customer reference) for this line item
project_code: Project code associated with this line item (optional)
note: Annotation for the item
@@ -1778,6 +1780,15 @@ class OrderLineItem(InvenTree.models.InvenTreeMetadataModel):
update_order = kwargs.pop('update_order', True)
# Update the integer representation of the line number (for natural sorting)
if self.line:
try:
self.line_int = int(self.line)
except (TypeError, ValueError):
self.line_int = 0
else:
self.line_int = 0
super().save(*args, **kwargs)
if update_order and self.order:
self.order.save()
@@ -1819,6 +1830,8 @@ class OrderLineItem(InvenTree.models.InvenTreeMetadataModel):
help_text=_('Line number for this item (optional)'),
)
line_int = models.IntegerField(default=0, blank=False, null=False)
reference = models.CharField(
max_length=100,
blank=True,