refactor: move item_code
reactivity to server-side
#44293
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Selecting an
Item
is the most common action in Sales / Purchase cycle. Whenever an Item is selected, system fetches the basic details like rate, discounts, stock qty, warehouse and sales account as such and auto-fills these details in it's respective fields. These can simply be called as Reactivity.All of this is achieved by a JS trigger on
item_code
located in transaction.jserpnext/erpnext/public/js/controllers/transaction.js
Lines 499 to 678 in 5266f23
But, due to a lack of UI test cases, this Reactivity is prone to regression, especially the ones related to discounts and free items. Check #42195 for more broken cases on Pricing Rules.
Long-Term Stability and Maintenance
To prevent frequent regression, moving most of the Reactivity to the server-side code makes sense, as it allows for server-side tests and a single source to maintain.
This PR is the first in that direction. It moves all of the UI Reactivity associated with
Item
selection to service-side.