mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improve introspection in migration file
This commit is contained in:
parent
725a64c29d
commit
ed4da4d338
@ -54,10 +54,14 @@ def update_history(apps, schema_editor):
|
||||
tracking_type = StockHistoryCode.BUILD_OUTPUT_COMPLETED
|
||||
|
||||
elif 'removed' in title and 'item' in title:
|
||||
tracking_type = StockHistoryCode.STOCK_REMOVE
|
||||
|
||||
if entry.notes.lower().startswith('split '):
|
||||
tracking_type = StockHistoryCode.SPLIT_CHILD_ITEM
|
||||
else:
|
||||
tracking_type = StockHistoryCode.STOCK_REMOVE
|
||||
|
||||
# Extract the number of removed items
|
||||
result = re.search("^removed ([\d\.]+) items$", title)
|
||||
result = re.search("^removed ([\d\.]+) items", title)
|
||||
|
||||
if result:
|
||||
|
||||
@ -70,9 +74,13 @@ def update_history(apps, schema_editor):
|
||||
deltas['quantity'] = float(q)
|
||||
except:
|
||||
print(f"WARNING: Error converting removed quantity '{removed}'")
|
||||
else:
|
||||
print(f"Could not decode '{title}'")
|
||||
|
||||
elif 'split from existing' in title:
|
||||
tracking_type = StockHistoryCode.SPLIT_FROM_PARENT
|
||||
|
||||
deltas['quantity'] = float(q)
|
||||
|
||||
elif 'moved to' in title:
|
||||
tracking_type = StockHistoryCode.STOCK_MOVE
|
||||
@ -93,7 +101,7 @@ def update_history(apps, schema_editor):
|
||||
tracking_type = StockHistoryCode.STOCK_ADD
|
||||
|
||||
# Extract the number of added items
|
||||
result = re.search("^added ([\d\.]+) items$", title)
|
||||
result = re.search("^added ([\d\.]+) items", title)
|
||||
|
||||
if result:
|
||||
|
||||
@ -107,6 +115,9 @@ def update_history(apps, schema_editor):
|
||||
except:
|
||||
print(f"WARNING: Error converting added quantity '{added}'")
|
||||
|
||||
else:
|
||||
print(f"Could not decode '{title}'")
|
||||
|
||||
elif 'assigned to customer' in title:
|
||||
tracking_type = StockHistoryCode.SENT_TO_CUSTOMER
|
||||
|
||||
|
@ -641,8 +641,8 @@ class StockItem(MPTTModel):
|
||||
tracking_info['location_name'] = location.name
|
||||
|
||||
if self.customer:
|
||||
tracking_info['customer'] = customer.id
|
||||
tracking_info['customer_name'] = customer.name
|
||||
tracking_info['customer'] = self.customer.id
|
||||
tracking_info['customer_name'] = self.customer.name
|
||||
|
||||
self.add_tracking_entry(
|
||||
StockHistoryCode.RETURNED_FROM_CUSTOMER,
|
||||
@ -849,7 +849,7 @@ class StockItem(MPTTModel):
|
||||
StockHistoryCode.REMOVED_CHILD_ITEM,
|
||||
user,
|
||||
deltas={
|
||||
'stockitem': self.pk,
|
||||
'stockitem': self.pk,
|
||||
},
|
||||
notes=notes,
|
||||
url=self.get_absolute_url(),
|
||||
@ -1183,11 +1183,6 @@ class StockItem(MPTTModel):
|
||||
|
||||
return True
|
||||
|
||||
if self.location:
|
||||
msg = _("Moved to {loc_new} (from {loc_old})").format(loc_new=str(location), loc_old=str(self.location))
|
||||
else:
|
||||
msg = _('Moved to {loc_new}').format(loc_new=str(location))
|
||||
|
||||
self.location = location
|
||||
|
||||
tracking_info = {}
|
||||
|
Loading…
Reference in New Issue
Block a user