mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 20:46:47 +00:00
Improve stock item splitting
This commit is contained in:
parent
90a342fad8
commit
3cef5c93ce
@ -492,20 +492,12 @@ class StockItem(models.Model):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Create a new StockItem object, duplicating relevant fields
|
# Create a new StockItem object, duplicating relevant fields
|
||||||
new_stock = StockItem.objects.create(
|
# Nullify the PK so a new record is created
|
||||||
part=self.part,
|
new_stock = StockItem.objects.get(pk=self.pk)
|
||||||
quantity=quantity,
|
new_stock.quantity = quantity
|
||||||
supplier_part=self.supplier_part,
|
|
||||||
location=self.location,
|
|
||||||
notes=self.notes,
|
|
||||||
URL=self.URL,
|
|
||||||
batch=self.batch,
|
|
||||||
delete_on_deplete=self.delete_on_deplete
|
|
||||||
)
|
|
||||||
|
|
||||||
new_stock.save()
|
new_stock.save()
|
||||||
|
|
||||||
# Copy the transaction history
|
# Copy the transaction history of this part into the new one
|
||||||
new_stock.copyHistoryFrom(self)
|
new_stock.copyHistoryFrom(self)
|
||||||
|
|
||||||
# Add a new tracking item for the new stock item
|
# Add a new tracking item for the new stock item
|
||||||
|
Loading…
x
Reference in New Issue
Block a user