Skip to content

Optimize stock availability query and fix configuration issues#227

Closed
Kushalnahata17 wants to merge 6 commits intoBrainWise-DEV:developfrom
Reformiqo:claude/setup-posnext-app-DnzsF
Closed

Optimize stock availability query and fix configuration issues#227
Kushalnahata17 wants to merge 6 commits intoBrainWise-DEV:developfrom
Reformiqo:claude/setup-posnext-app-DnzsF

Conversation

@Kushalnahata17
Copy link
Copy Markdown

Summary

This PR optimizes the stock availability lookup query and fixes configuration issues in the project setup files.

Key Changes

Stock Availability Query Optimization (pos_next/api/items.py)

  • Replaced ORM with direct SQL query: Changed from frappe.get_all() to frappe.db.sql() for improved performance when querying stock levels across multiple warehouses
  • Added empty warehouse list check: Added early return when no warehouses are found to avoid unnecessary database queries
  • Improved null handling: Enhanced the return statement to safely handle cases where actual_qty might be null
  • Added missing import: Imported flt utility function from frappe.utils
  • Removed commented code: Cleaned up the old implementation that was left as a comment

Configuration Fixes

  • Fixed pyproject.toml description: Corrected malformed quote character in the project description string
  • Added Frappe dependencies: Added explicit version constraints for frappe (>=15.0.0,<17.0.0) and erpnext (>=15.0.0,<17.0.0) in the build configuration
  • Added lodash resolution: Added package resolution for lodash to version 4.17.21 in POS/package.json to address potential security or compatibility concerns

Implementation Details

The stock availability query now uses raw SQL with parameterized queries for better performance when dealing with group warehouses that may have many child warehouses. The query aggregates stock quantities at the database level rather than in application code, reducing memory overhead and improving response times.

https://claude.ai/code/session_01HwkTrrrzwXWuoNfGnFtCQr

khanmomodou101 and others added 6 commits February 18, 2026 16:47
…tion

lodash 4.18.0 removed `assignWith` from template scope, breaking
workbox-build's SW template compilation during `bench build`.

https://claude.ai/code/session_01HwkTrrrzwXWuoNfGnFtCQr
Remove commented-out code and duplicate import left by 755e02b,
keeping the optimized SQL-based get_stock_availability function.

https://claude.ai/code/session_01HwkTrrrzwXWuoNfGnFtCQr
- Add missing "variant_of" field to ITEM_RESULT_FIELDS
- Use Query Builder (frappe.qb) instead of raw SQL for get_stock_availability
  to match BrainWise-DEV:develop

https://claude.ai/code/session_01HwkTrrrzwXWuoNfGnFtCQr
Copy link
Copy Markdown
Author

@Kushalnahata17 Kushalnahata17 left a comment

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Author

@Kushalnahata17 Kushalnahata17 left a comment

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

@engahmed1190 engahmed1190 left a comment

Choose a reason for hiding this comment

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

Code Review — CLOSE (All changes already on develop)

All three changes in this PR are already present on develop:

  1. pos_next/api/items.py — The variant_of field addition to ITEM_RESULT_FIELDS and the frappe.qb stock query refactor were merged in prior work. The file on develop is identical to this PR's version.

  2. pyproject.toml — The malformed quote fix and [tool.bench.frappe-dependencies] section are already on develop.

  3. POS/package.json — The lodash resolution is already present on develop.

Diffing this PR's HEAD against develop produces zero differences across all three files. The PR's merge state is UNSTABLE because there's nothing left to merge.

Recommend closing as superseded.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants