erpnext
erpnext copied to clipboard
feat: Share Serial Nos between unique Items
no-docs (temporary)
Case:
- Serial Nos are purchased from Supplier and must be maintained in the system as per supplier
- A company buys different items from a supplier, who (supplier) starts all their serialised items with 1 and then autoincrements. This way item A can have serial “3” and item B can also have serial no “3”.
- Additionally: A serial no is also something that a supplier/ manufacturer can choose freely.
Solution:
- Make Serial Nos unique only on Item level (Item A cannot have Serial No "3" twice)
- This means Item A and B can have the same Serial No, but different Serial No document names
Flow:
- Serialised Item A receives some Serial Nos via a Purchase Receipt. These are auto created using a naming series. SN-0001 is one of them
- We want to register a Serial No for Serialised Item B, which also has the same Serial No
- We can do one of the following:
- Create a new Serial No (manual or data import) > Use it in the new Purchase Receipt's popup, by scanning or entering it in the table
- In the new Purchase Receipt popup, upload a CSV of the Serial No(s).
- Create a new Serial and Batch Bundle > click on "Make Serial Nos" in the form > insert/upload the Serial No(s)
- Now we should have a Serial and Batch Bundle created that includes a Serial No with ID: SN-0001-1 and Serial No: SN-0001
All of the above methods handle naming clashes via the autoname function in the Serial No.
Note: This does not work for naming series (auto naming) as the last count is maintained series wise. So if we have a series
SN-.####shared by two items, the insertion of the Item-A creates SN-0001 (series count is 1) and then the following insertion of Item-B will naturally create SN-0002.
For now only manual addition of serial no.s through various modes is supported for reusability
ToDo:
- [x] Link formatting for Serial No in tables and reports
- [x] Tests
Codecov Report
Attention: Patch coverage is 70.32967% with 27 lines in your changes are missing coverage. Please review.
Project coverage is 60.13%. Comparing base (
d0df5df) to head (f8a8f5b). Report is 767 commits behind head on develop.
:exclamation: Current head f8a8f5b differs from pull request most recent head 162732d. Consider uploading reports for the commit 162732d to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## develop #37209 +/- ##
===========================================
- Coverage 60.24% 60.13% -0.12%
===========================================
Files 758 757 -1
Lines 71199 70533 -666
===========================================
- Hits 42893 42414 -479
+ Misses 28306 28119 -187
| Files | Coverage Δ | |
|---|---|---|
| ...xt/accounts/doctype/sales_invoice/sales_invoice.py | 74.39% <100.00%> (+0.07%) |
:arrow_up: |
| ...ctype/maintenance_schedule/maintenance_schedule.py | 71.98% <100.00%> (ø) |
|
| erpnext/stock/report/stock_ageing/stock_ageing.py | 91.07% <100.00%> (ø) |
|
| erpnext/stock/stock_ledger.py | 83.50% <100.00%> (+2.99%) |
:arrow_up: |
| ...rpnext/accounts/doctype/pos_invoice/pos_invoice.py | 49.69% <0.00%> (+0.31%) |
:arrow_up: |
| erpnext/controllers/accounts_controller.py | 85.33% <0.00%> (-0.23%) |
:arrow_down: |
| erpnext/controllers/sales_and_purchase_return.py | 91.18% <50.00%> (ø) |
|
| erpnext/controllers/stock_controller.py | 81.73% <50.00%> (-1.75%) |
:arrow_down: |
| erpnext/controllers/subcontracting_controller.py | 89.38% <0.00%> (-0.06%) |
:arrow_down: |
| ...ext/manufacturing/doctype/work_order/work_order.py | 75.46% <75.00%> (+0.09%) |
:arrow_up: |
| ... and 9 more |
@rohitwaghchaure Whenever you can please take a look. Would love to get your review :)
TODO: Add more tests for stock transfer, stock reservation, delivery note
This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.
True, the Serial Number can’t be unique across all items. However, if it isn’t unique, so we need a separate unique ID, then I think it’s less confusing if that unique ID is a random hash. We certainly don‘t want users to confuse the two. Also, unlike with, say, amended submittable documents, there may be nothing two accidentally identical S/Ns that are referring to different items have in common.
Still we may want an additional provision allowing to enforce unique serial numbers over a particular Item Group, as for some items out in the world, general standards for S/N exist. But that‘s matter for a separate ticket.
@bosue this PR is supposed to get backported all the way to v14, so we can't just change the naming scheme. This is a completely optional approach, for users who are aware of the implications. Regarding future versions I agree with you, but that will have to be a separate PR.
@barredterra To Test:
- Enable the setting
- Create two serialised items. Let the first item be autonamed and create serial nos for it (Purchase Receipt) (eg. SN-001, SN-002, etc.)
To insert Serial Nos for the second item, these are multiple ways to achieve the same goal :
- Use the "Download Template" > "Attach CSV" feature. Make sure the CSV has SN-002 (same as the first item) and any other SN. The expectation is that the the new SN should be created under the name SN-002-1
- Manually create a Serial No from the serial no. list view and select it in the popup above. A duplicate Serial No of another item should work just fine
- Use Data Import to insert a duplicate Serial No record
- In "Serial and Batch Bundle", fill in the basic details, click on "Make Serial Nos", try inserting a duplicate using the text field and CSV.
To move the serial no:
- In a Delivery Note, use the Scan Serial No field in the Serial No popup. The expectation is that if SN-002 is scanned for the second item, the table in the popup should be populated with SN-002-1
- The same can be checked for a stock entry where the Serial No is transferred from one warehouse to another
- The same check can be done for a Serial and Batch Item, along with the right Serial No ID, the right batch no. will be populated in the popup table too
Stock Reservation:
- Enable Stock Reservation in Stock Settings https://docs.erpnext.com/docs/user/manual/en/stock-reservation and also enable auto reserve serial and batch nos
- Create a Sales Order for the second Serial No (with duplicate) > submit > Reserve stock
- Check that the created stock reservation entry has our duplicate serial no with the right name that links to the right record
You can check the PR description where Serial No. link formatting is also fixed in this PR for a duplicate case.
@rohitwaghchaure please give this a look for any potential breaking issues ?
Linter failure is unrelated; fixed in https://github.com/frappe/erpnext/pull/39511
@rohitwaghchaure since you are the expert on this topic, we would really appreciate your review and guidance on this PR.
Manual tests completed
Before – after comparison of reports:
- [x] Cost of poor Quality (no data)
- [x] Incorrect Serial No Valuation (no data)
- [x] Serial No Ledger
- [x] Stock Ledger
- [x] Stock Qty vs Serial No Count
Sales and Purchase Cycle with one serialized and one non-serialized item. Setting "Allow Duplicate Serial Nos Across Items" disabled.
- [x] Purchase Order
- [x] Purchase Receipt
- [x] Stock Entry (Type: "Material Transfer")
- [x] Stock Reconciliation
- [x] Sales Order
- [ ] Stock Reservation
- [ ] Subcontracting
- [x] Delivery Note
Sales and Purchase Cycle with one serialized and one non-serialized item. Setting "Allow Duplicate Serial Nos Across Items" enabled.
- [x] Purchase Order
- [x] Purchase Receipt
- [x] Stock Entry (Type: "Material Transfer")
- [x] Stock Reconciliation
- [x] Sales Order
- [ ] Stock Reservation
- [ ] Subcontracting
- [x] Delivery Note
Found few failed cases during the testing
- User Serial / Batch fields feature not working
- Created same serial number with different items first
- While making the purchase receipt, enabled "Use Serial / Batch Fields" checkbox in the line item.
- Enter the Serial Number created at step 1 and submitted
- System has created new serial number with has value, also system has ignored "Serial Number Series" from the item master while creating new serial no (primary key should has value not the serial no field's value)
- Getting below error while making the stock reconciliation with User Serial / Batch fields
ToDo:
Test Serial No Series, if autoname obstructs serial no series naming- text field should have serial no (and not name) and name should be handled on the backend
- Case: Scanning serial no does not know which item the srrial no belongs to, same with POS
This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.