2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-10 23:14:13 +00:00

Stock history fix (#4541)

* Fix bug in allocateToCustomer method

* Data migration to alter stock tracking history with new codes and data

* Prevent note duplication
This commit is contained in:
Oliver
2023-03-30 23:30:16 +11:00
committed by GitHub
parent 47f52478e0
commit d0bf4cb81a
2 changed files with 77 additions and 5 deletions

View File

@ -961,11 +961,13 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, common.models.MetaMixin, M
item.save(add_note=False)
code = StockHistoryCode.SENT_TO_CUSTOMER
deltas = {
'customer': customer.pk,
'customer_name': customer.pk,
}
deltas = {}
if customer is not None:
deltas['customer'] = customer.pk
deltas['customer_name'] = customer.name
# If an order is provided, we are shipping against a SalesOrder, not manually!
if order:
code = StockHistoryCode.SHIPPED_AGAINST_SALES_ORDER
deltas['salesorder'] = order.pk
@ -1031,7 +1033,7 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, common.models.MetaMixin, M
notes=notes
)
else:
self.save()
self.save(add_note=False)
def is_allocated(self):
"""Return True if this StockItem is allocated to a SalesOrder or a Build."""