Skip to content

Conversation

@Packeting1
Copy link

Resovles Frappe Issue #35455

Skip process_item_selection while Item Quick Entry is open from a link to avoid “Item not found”.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

📝 Walkthrough

Walkthrough

The change adds an early return in the Item handling flow in erpnext/public/js/controllers/transaction.js to skip the server-side process_item_selection call when an item is entered via Item Quick Entry and has not yet been saved. The early return triggers when from_link.field_obj.df.fieldname equals "item_code" and from_link.field_obj.get_options() returns "Item", preventing the server request in that specific context.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: skipping the item selection call when Item Quick Entry is open, which matches the actual code modification.
Description check ✅ Passed The description is related to the changeset, explaining the motivation (resolving Issue #35455) and what the fix does (skip process_item_selection to avoid 'Item not found' error).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 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 506a8de and 17ccee7.

📒 Files selected for processing (1)
  • erpnext/public/js/controllers/transaction.js
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: sagarvora
Repo: frappe/erpnext PR: 50155
File: erpnext/controllers/accounts_controller.py:2992-3005
Timestamp: 2025-10-17T14:11:06.959Z
Learning: In ERPNext, item child doctypes (like "Sales Invoice Item", "Delivery Note Item", etc.) have exactly one non-custom Link field that references their parent transaction doctype (like "Sales Order", "Purchase Order", etc.). This is a schema design pattern that can be relied upon when determining reference fields for mapping logic.
⏰ 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 (1)
erpnext/public/js/controllers/transaction.js (1)

615-623: Fix correctly prevents process_item_selection during Item Quick Entry flow.

The early return appropriately guards against the "Item not found" error by skipping process_item_selection when Item Quick Entry is opened from a link field. The placement before the use_legacy_js_reactivity check ensures both code paths are protected, and the detection logic is properly scoped—checking for both the item_code fieldname and Item doctype.

frappe._from_link is a Frappe framework global that manages the quick entry lifecycle, not an ERPNext-specific variable. The framework sets it when a form is opened from a link field and clears it after the Quick Entry completes, ensuring normal item processing resumes automatically.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 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 cb5926f and 6a5756a.

📒 Files selected for processing (1)
  • erpnext/public/js/controllers/transaction.js
🧰 Additional context used
🧬 Code graph analysis (1)
erpnext/public/js/controllers/transaction.js (1)
erpnext/accounts/doctype/payment_entry/payment_entry.js (1)
  • frappe (1709-1709)
⏰ 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 (2)
erpnext/public/js/controllers/transaction.js (2)

619-627: Clarify the "two locations" mentioned in the AI summary.

The AI-generated summary states: "This change appears in two locations of the Item handling flow, effectively preventing the server request in both contexts." However, only one early return is visible in the provided code (lines 619-627).

Could you clarify:

  1. Is there another location in this file or another file where a similar check should be added?
  2. Or does "two locations" refer to something else in the implementation?

This will help ensure complete coverage of the fix.


619-627: Verify cleanup and timing guarantees for frappe._from_link with the Frappe framework team.

The frappe._from_link check is intentionally defensive with scoped field validation, but relies on framework-level cleanup that cannot be verified from the erpnext codebase alone. The code is marked "Experimental" and designed to work with frappe.run_serially() sequencing (where item_code() triggers again after Quick Entry saves), suggesting cleanup is expected between calls. However, confirm with Frappe maintainers:

  • Whether frappe._from_link is guaranteed to be cleared after Quick Entry completes
  • If this pattern is officially recommended or if a more robust API exists
  • Whether the timing guarantees hold under concurrent saves or network delays

Consider adding a safeguard to explicitly clear or validate the state before the second item_code() trigger executes.

@Packeting1 Packeting1 force-pushed the fix/quick-entry-link-item branch from 506a8de to 17ccee7 Compare December 31, 2025 06:52
@rohitwaghchaure
Copy link
Collaborator

Fixed #51607

@Packeting1 Packeting1 deleted the fix/quick-entry-link-item branch January 9, 2026 00:52
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.

2 participants