Skip to content

Commit d647eea

Browse files
Revert "Handle list returns from creating StockItems"
1 parent 58b0617 commit d647eea

File tree

3 files changed

+2
-52
lines changed

3 files changed

+2
-52
lines changed

inventree/stock.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
import inventree.report
1212

1313

14-
logger = logging.getLogger('inventree')
15-
16-
1714
class StockLocation(
1815
inventree.base.BarcodeMixin,
1916
inventree.base.MetadataMixin,
@@ -61,31 +58,6 @@ class StockItem(
6158

6259
MODEL_TYPE = 'stockitem'
6360

64-
@classmethod
65-
def create(cls, api, data, **kwargs):
66-
""" Override default create method to support multiple object return. """
67-
68-
cls.checkApiVersion(api)
69-
70-
# Ensure the pk value is None so an existing object is not updated
71-
if cls.getPkField() in data.keys():
72-
data.pop(cls.getPkField())
73-
74-
response = api.post(cls.URL, data, **kwargs)
75-
76-
if response is None:
77-
logger.error("Error creating new object")
78-
return None
79-
80-
if isinstance(response, list):
81-
allResponses = []
82-
for element in response:
83-
allResponses.append(cls(api, data=element))
84-
return allResponses
85-
86-
else:
87-
return [cls(api, data=response)]
88-
8961
@classmethod
9062
def adjustStockItems(cls, api: inventree.api.InvenTreeAPI, method: str, items: list, **kwargs):
9163
"""Perform a generic stock 'adjustment' action.

test/test_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ def test_create_stuff(self):
209209
'part': p.pk,
210210
'quantity': 45,
211211
'notes': 'This is a note',
212-
})[0]
212+
213+
})
213214

214215
self.assertIsNotNone(s)
215216
self.assertEqual(s.part, p.pk)

test/test_stock.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -248,25 +248,6 @@ def test_barcode_support(self):
248248

249249
item.unassignBarcode()
250250

251-
def test_serialized(self):
252-
"""Test serializing multiple objects on create"""
253-
254-
# Create items with serial numbers
255-
items = StockItem.create(
256-
self.api,
257-
{
258-
"part": 10004,
259-
"quantity": 3,
260-
"serial_numbers": "1005,1006,1007"
261-
}
262-
)
263-
264-
self.assertEqual(3, len(items))
265-
266-
self.assertEqual('1005', items[0].serial)
267-
self.assertEqual('1006', items[1].serial)
268-
self.assertEqual('1007', items[2].serial)
269-
270251

271252
class StockAdjustTest(InvenTreeTestCase):
272253
"""Unit tests for stock 'adjustment' actions"""
@@ -426,10 +407,6 @@ def test_assign_stock(self):
426407
}
427408
)
428409

429-
# Verify a single result was returned
430-
self.assertEqual(1, len(assignitem))
431-
assignitem = assignitem[0]
432-
433410
# Assign the item
434411
assignitem.assignStock(customer=customer, notes='Sell on the side')
435412

0 commit comments

Comments
 (0)