Skip to content

Conversation

@SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented Aug 14, 2025

Improve API endpoint for receiving multiple line items against a purchase order.

Receiving items individually is very expensive (in terms of DB performance) and can cause the request to timeout.

Changes

  • Add receive_line_items method for PurchaseOrder model
  • Improve query efficiency for plugin registry
  • Various optimizations

Profiling

Comparing the number of database queries when receiving N line items via the API:

Line Count Old Code New Code
10 545 109
50 2545 189
250 > 9,000 589
500 > 9,000 1089

Tasks

  • Add unit test for receiving many line items agains
  • Serializer should return list of created items
  • Comparative profiling data
  • Update unit tests for python bindings - Tweak unit tests inventree-python#277

- Make model operations more efficient
- Cache config map against the session cache
- Pass multiple line items in simultaneously
- DB query optimization
- Use bulk_create and bulk_update operations
@SchrodingersGat SchrodingersGat added this to the 1.0.0 milestone Aug 14, 2025
@SchrodingersGat SchrodingersGat added the order Related to purchase orders / sales orders label Aug 14, 2025
@SchrodingersGat SchrodingersGat added api Relates to the API refactor User Interface Related to the frontend / User Interface labels Aug 14, 2025
@netlify
Copy link

netlify bot commented Aug 14, 2025

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

Name Link
🔨 Latest commit fd0a60b
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/689f144edd137e0008e5c2e3

@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 93.67816% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.12%. Comparing base (3e37550) to head (fd0a60b).
⚠️ Report is 306 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10174   +/-   ##
=======================================
  Coverage   87.12%   87.12%           
=======================================
  Files        1258     1258           
  Lines       55883    55955   +72     
  Branches     2080     2078    -2     
=======================================
+ Hits        48690    48753   +63     
- Misses       6682     6691    +9     
  Partials      511      511           
Flag Coverage Δ
backend 88.82% <93.67%> (+<0.01%) ⬆️

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

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

@SchrodingersGat SchrodingersGat merged commit 0bed5cf into inventree:master Aug 15, 2025
32 checks passed
@SchrodingersGat SchrodingersGat deleted the po-receive-fix branch August 15, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API order Related to purchase orders / sales orders refactor User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant