mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-01 17:51:23 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user