-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Share Serial Nos between unique Items #37209
Conversation
2148383
to
a3af740
Compare
Codecov ReportAttention: Patch coverage is
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
|
@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. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tidbits.
If we already know that at a later point – preferably soon – we want to allow Uniqueness per Item Group as a third option, we might want to use a select rightaway so we're flexible. But it‘s perfectly fine to keep it simple now.
@barredterra To Test:
To insert Serial Nos for the second item, these are multiple ways to achieve the same goal :
To move the serial no:
Stock Reservation:
You can check the PR description where Serial No. link formatting is also fixed in this PR for a duplicate case. |
- Amend Serial No name on Insertion of Serial No if it has a duplicate in another item - `get_serial_nos` must accept item_code since serial not can be same for different items. - SN text fields contain the Serial No not the docname - Removed `get_serial_nos_data`
- If duplicate serial nos are allowed, `get_serial_nos` requires item code, throw error. - Else, `item_code` is optional for backwards compatibility
- On uploading new Serial Nos via CSV, make new SNs and insert SN Name in serial batch bundle - Remove unused args & pass item_code to `get_available_serial_nos`
`serial_no` is a link field, so `serial_no_name` seems redundant.
Linter failure is unrelated; fixed in #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:
Sales and Purchase Cycle with one serialized and one non-serialized item. Setting "Allow Duplicate Serial Nos Across Items" disabled.
Sales and Purchase Cycle with one serialized and one non-serialized item. Setting "Allow Duplicate Serial Nos Across Items" enabled.
|
ToDo:
|
if frappe.db.exists("Serial No", {"serial_no": self.serial_no, "item_code": self.item_code}): | ||
frappe.throw( | ||
msg=_("Serial No {0} already exists for Item {1}").format( | ||
frappe.bold(self.serial_no), frappe.bold(self.item_code) | ||
), | ||
title=_("Duplicate"), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While validation is fine, this should also be a DB level unique constraint using db.add_unique
we have had many such problem with Bin
where ORM level validations are not sufficient.
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. |
no-docs
(temporary)Case:
Solution:
Flow:
All of the above methods handle naming clashes via the
autoname
function in the Serial No.ToDo: