diff --git a/src/backend/InvenTree/stock/models.py b/src/backend/InvenTree/stock/models.py index 8a12bde90d..f9b943969d 100644 --- a/src/backend/InvenTree/stock/models.py +++ b/src/backend/InvenTree/stock/models.py @@ -2180,7 +2180,7 @@ class StockItem( return True def find_merge_target(self, location): - """Find an existing stock item at *location* that can absorb this item.""" + """Find an existing stock item at location that can absorb this item.""" if location is None: return None @@ -2215,11 +2215,8 @@ class StockItem( *This* stock item subsumes the other, which is essentially deleted: - The quantity of this StockItem is increased - - Tracking history for the *other* item is copied to this item (unless copy_history=False) + - Tracking history for the *other* item is deleted - Any allocations (build order, sales order) are moved to this StockItem - - kwargs: - copy_history: If True (default), copy tracking from merged items. Set False for merge-on-transfer. """ if isinstance(other_items, StockItem): other_items = [other_items] @@ -2233,7 +2230,6 @@ class StockItem( user = kwargs.get('user') location = kwargs.get('location', self.location) notes = kwargs.get('notes') or '' - copy_history = kwargs.pop('copy_history', True) parent_id = self.parent.pk if self.parent else None @@ -2278,9 +2274,6 @@ class StockItem( self.parent = None self.save() - if copy_history: - self.copyHistoryFrom(other) - if other.location: location_note = _('Transferred from %(location)s') % { 'location': other.location.pathstring diff --git a/src/backend/InvenTree/stock/serializers.py b/src/backend/InvenTree/stock/serializers.py index 7ca257cfcb..231fbaa292 100644 --- a/src/backend/InvenTree/stock/serializers.py +++ b/src/backend/InvenTree/stock/serializers.py @@ -1893,7 +1893,6 @@ class StockTransferSerializer(StockAdjustmentSerializer): 'location': location, 'notes': notes, 'user': request.user, - 'copy_history': False, **kwargs, } diff --git a/src/backend/InvenTree/stock/tests.py b/src/backend/InvenTree/stock/tests.py index aa453025f4..999fc030b0 100644 --- a/src/backend/InvenTree/stock/tests.py +++ b/src/backend/InvenTree/stock/tests.py @@ -722,20 +722,12 @@ class StockTest(StockTestBase): s2 = StockItem.objects.create(part=part, quantity=20) s3 = StockItem.objects.create(part=part, quantity=30) - s2.add_tracking_entry( - StockHistoryCode.STOCK_UPDATE, None, notes='Merged away tracking' - ) - - tracking_before = s1.tracking_info.count() - self.assertEqual(part.stock_items.count(), 3) s1.merge_stock_items([s2, s3]) self.assertEqual(part.stock_items.count(), 1) s1.refresh_from_db() self.assertEqual(s1.quantity, 60) self.assertIsNone(s1.purchase_price) - self.assertTrue(s1.tracking_info.filter(notes='Merged away tracking').exists()) - self.assertGreater(s1.tracking_info.count(), tracking_before) merge_entry = s1.tracking_info.filter( tracking_type=StockHistoryCode.MERGED_STOCK_ITEMS