Skip to content

Conversation

@kavin-114
Copy link
Contributor

@kavin-114 kavin-114 commented Oct 21, 2025

Issue: When creating a Pick List against the partially picked Material Request, system is not calculating and passing the balance required quantity from MR.

Fix: System will update the qty when creating Pick List from MR as per the formula (Qty - Completed Qty) and only considers items if the balance quantity is above zero.

Ref: 50973

Before:

Screencast.from.21-10-25.08.24.46.PM.IST.webm

After:

Screencast.from.21-10-25.08.23.07.PM.IST.webm

While debugging the main issue, I identified an additional problem related to Transfer Entry creation from the Pick List and fixed it in the following commit:

Commit: f5860f2
Fix: Handled transfer quantity for multi-UOM items when creating a transfer from a pick list.

Backport Needed: v15

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Oct 21, 2025
@kavin-114 kavin-114 marked this pull request as ready for review October 24, 2025 10:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

📝 Walkthrough

Walkthrough

This change modifies how Pick List items are created from Material Requests and updates quantity calculations in Pick Lists. In the Material Request module, a new helper function computes Pick List Item quantities by calculating the surplus stock as (stock_qty - ordered_qty) / conversion_factor, and filters to include only items where surplus stock exists. In the Pick List module, the quantity computation for Stock Entry items is simplified from using picked_qty * conversion_factor to directly using qty.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The changes span two files with logic modifications affecting quantity calculations in the stock management workflow. The Material Request changes introduce a new helper function with conditional logic and filtering conditions that require understanding the business rules around stock surplus detection. The Pick List change, while a single-line modification, involves a computation that directly impacts Stock Entry item quantities. The heterogeneous nature of these changes across different modules and their impact on core stock operations warrants moderate review attention.

Suggested reviewers

  • rohitwaghchaure
  • mihir-kandoi

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "fix: Update pick list locations quantity" clearly describes the primary change in the pull request. The changeset updates how quantities are calculated for pick list items, both in the Material Request's create_pick_list method (applying the formula (stock_qty - ordered_qty) / conversion_factor) and in the Pick List's update_common_item_properties method (using location.qty instead of location.picked_qty * conversion_factor). The title is concise, specific enough for a developer scanning history to understand the purpose, and directly related to the main objective of fixing quantity calculations in pick list locations.
Description Check ✅ Passed The pull request description is well-related to the changeset and provides meaningful information about the changes. It clearly explains the issue (balance quantity not calculated when creating a Pick List from a partially picked Material Request), states the specific fix (using the formula (Qty - Completed Qty) and filtering for positive balance quantities), and references the support ticket. The description also mentions an additional related fix for multi-UOM items and provides before/after screencasts, all of which are relevant to the code changes in both material_request.py and pick_list.py.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f51ed30 and f5860f2.

📒 Files selected for processing (2)
  • erpnext/stock/doctype/material_request/material_request.py (2 hunks)
  • erpnext/stock/doctype/pick_list/pick_list.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
erpnext/stock/doctype/material_request/material_request.py (3)
erpnext/buying/doctype/purchase_order/purchase_order.py (2)
  • update_item (762-768)
  • update_item (851-873)
erpnext/selling/doctype/sales_order/sales_order.py (5)
  • update_item (1013-1037)
  • update_item (1179-1194)
  • update_item (1313-1347)
  • update_item (1595-1599)
  • update_item (1745-1749)
erpnext/utilities/transaction_base.py (1)
  • conversion_factor (403-421)
🪛 Ruff (0.14.1)
erpnext/stock/doctype/material_request/material_request.py

890-890: Unused function argument: source_parent

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Summary
🔇 Additional comments (3)
erpnext/stock/doctype/pick_list/pick_list.py (1)

1552-1564: LGTM! Multi-UOM quantity handling corrected.

The change from location.picked_qty * location.conversion_factor to location.qty correctly fixes the Stock Entry quantity calculation for multi-UOM items. The previous formula incorrectly doubled the conversion, while the new approach directly uses the quantity already in the correct UOM from the Pick List Item.

The relationship transfer_qty = qty * conversion_factor is now properly maintained:

  • transfer_qty = location.picked_qty (stock UOM quantity)
  • qty = location.qty (UOM-specific quantity)
  • conversion_factor = location.conversion_factor
erpnext/stock/doctype/material_request/material_request.py (2)

890-898: Correct balance quantity calculation.

The update_item helper correctly computes the balance quantity for partially picked Material Requests using the formula (stock_qty - ordered_qty) / conversion_factor. This ensures Pick Lists only include items with remaining quantities.

Note: The static analysis warning about the unused source_parent parameter is a false positive—the parameter is required to match the expected signature for the postprocess callback in get_mapped_doc.


909-917: Proper filtering for partially picked items.

The mapping configuration correctly filters Material Request Items to include only those with remaining quantities (ordered_qty < stock_qty). The precision-based comparison prevents floating-point equality issues, and the postprocess callback properly computes balance quantities.

The condition works in tandem with the update_item function to ensure only items requiring additional picking are included in the Pick List.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mihir-kandoi mihir-kandoi self-assigned this Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport version-15-hotfix needs-tests This PR needs automated unit-tests.

3 participants