Skip to content

[API] Return stock item list when creating multiple items - #9857

Merged
SchrodingersGat merged 6 commits into
inventree:masterfrom
SchrodingersGat:create-build-output
Jun 25, 2025
Merged

SchrodingersGat merged 6 commits into
inventree:masterfrom
SchrodingersGat:create-build-output

Conversation

@SchrodingersGat

Copy link
Copy Markdown
Member

@netlify

netlify Bot commented Jun 25, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit dede8b1
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/685c03282f52c20008d26edc

@SchrodingersGat SchrodingersGat added stock Related to Stock models api Relates to the API labels Jun 25, 2025
@SchrodingersGat SchrodingersGat added this to the 1.0.0 milestone Jun 25, 2025
@codecov

codecov Bot commented Jun 25, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.05128% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.60%. Comparing base (6915ed5) to head (dede8b1).
⚠️ Report is 310 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9857      +/-   ##
==========================================
- Coverage   86.61%   86.60%   -0.01%     
==========================================
  Files        1243     1243              
  Lines       54816    54850      +34     
  Branches     2230     2230              
==========================================
+ Hits        47478    47504      +26     
- Misses       6772     6780       +8     
  Partials      566      566              
Flag Coverage Δ
backend 88.56% <82.05%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 91.24% <81.57%> (-0.03%) ⬇️
Backend General 92.51% <ø> (ø)
Frontend 69.78% <ø> (-0.01%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +1028 to +1031
# Exclude 'serial' from submitted data
# We use 'serial_numbers' for item creation
data.pop('serial', None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up, I got burned by this change because my clients used the serial keyword when using this API to create a single stock item.

I have no problem updating my clients to use serial_numbers instead. However, serial still appears in the API documentation. I saw the release blog post mention the return type being a list, so I probably should have seen this coming, but I overlooked it. I may not be the only one hitting this, took me a second to find this change and determine that's why it stopped working.

Would the correct thing be to remove serial from the StockItemSerializer? Or would this have other unintended consequences?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobfelknor good question, and a fair point that we should address.

The behavior here is not well documented, as the serial field applies to the serial number for a single stock item, but the serial_numbers is a write-only (and only on initial item creation) that allows you to specify multiple serial numbers for creating multiple stock items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API stock Related to Stock models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to obtain output id for /api/build/$buildId/complete/ endpoint?

2 participants