Skip to content
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: Serial and Batch reservation #35946

Merged
merged 108 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
c1fca7c
feat: add `Has Serial No` and `Has Batch No` fields in SRE
s-aga-r Jun 6, 2023
f8c6c62
chore: set `Has Serial No` and `Has Batch No` while creating SRE
s-aga-r Jun 6, 2023
3177a18
feat: add field `Reserved Serial and Batch` in SRE
s-aga-r Jun 6, 2023
387d9df
fix(ux): hide `Amend` button on cancelled SRE
s-aga-r Jun 6, 2023
7d3fc70
fix: add validation for SRE amended doc
s-aga-r Jun 6, 2023
f8bdece
fix(ux): hide `Reserved Serial and Batch` Table for non-serial/batch …
s-aga-r Jun 6, 2023
9882e8c
fix(ux): set `Display Depends On` for `Has Serial No` and `Has Batch …
s-aga-r Jun 6, 2023
57c40ef
fix(ux): make `serial_no` and `batch_no` fields read-only based on `h…
s-aga-r Jun 8, 2023
fcb1157
chore: remove table `Serial and Batch Entry` fieldlabel
s-aga-r Jun 8, 2023
3a03d68
fix(ux): set warehouse for new row
s-aga-r Jun 9, 2023
fc12ede
fix(ux): make qty field read-only for serial item
s-aga-r Jun 9, 2023
98b8a90
fix(ux): set rows qty to `1` before making the field read-only
s-aga-r Jun 9, 2023
34538f9
chore: add filters for serial no
s-aga-r Jun 11, 2023
9156176
chore: add filters for batch no
s-aga-r Jun 11, 2023
157c5f3
chore: don't show Serial NO if already selected
s-aga-r Jun 12, 2023
4232b46
chore: hide rate related fields
s-aga-r Jun 12, 2023
976fc8b
feat: add field `Reservation Based On` in SRE
s-aga-r Jun 12, 2023
ffffdca
chore: make `Reserved Qty` field editable in SCR
s-aga-r Jun 20, 2023
c2a3811
chore: add method to get total reserved qty against a voucher
s-aga-r Jun 20, 2023
3400e90
fix: add validation for `Reserved Qty`
s-aga-r Jun 21, 2023
d787ea8
fix: update SRE status and Voucher's Reserved Qty
s-aga-r Jun 21, 2023
462e0dd
chore: enable `Track Changes` in SRE
s-aga-r Jun 21, 2023
c9f2802
fix: add validation to prevent delivered SRE to get updated
s-aga-r Jun 21, 2023
1240613
fix(ux): make fields `Reserved Qty` and `Reservation Based On` read-o…
s-aga-r Jun 21, 2023
fbc5021
fix: consider voucher's delivered qty while calculating max reserved qty
s-aga-r Jun 22, 2023
4ef6929
fix: add UOM validation for SRE Reserved Qty
s-aga-r Jun 22, 2023
4e75f55
fix: SRE warehouse mismatch error in DN
s-aga-r Jun 22, 2023
3fb9931
fix: auto cancel SRE on update if item is fully delivered for the SO
s-aga-r Jun 22, 2023
4cc19fc
fix: skip SRE creation for group warehouse
s-aga-r Jun 22, 2023
94b56f7
feat: add `Set Warehouse` field in SO stock reservation dialog
s-aga-r Jun 23, 2023
dec0975
fix(ux): hide `Add Row` button in SO stock reservation dialog
s-aga-r Jun 23, 2023
e8f6c60
fix: group warehouse validation in SO
s-aga-r Jun 23, 2023
3ccb558
fix(ux): don't show Batch No if already selected
s-aga-r Jun 23, 2023
0c4dec2
feat: add field `Auto Reserve Serial and Batch Nos` in `Stock Settings`
s-aga-r Jun 26, 2023
5ed872c
refactor: SRE reserved qty validation
s-aga-r Jun 26, 2023
086b0d8
feat: auto serial and batch reservation
s-aga-r Jun 27, 2023
fe8d130
chore: add section for `Serial and Batch Reservation` in `Stock Setti…
s-aga-r Jun 27, 2023
d04beca
fix: make SRE sb_entries warehouse mandatory
s-aga-r Jun 27, 2023
dbe8b6b
fix(ux): unreserved qty calculation
s-aga-r Jun 28, 2023
e35933e
fix: add validation for `Reserved Qty` against `Batch`
s-aga-r Jun 28, 2023
41d3956
refactor: combine `get_available_qty_to_reserve()` and `get_available…
s-aga-r Jun 28, 2023
e93fc4c
fix: validate disabled batch
s-aga-r Jun 28, 2023
96f8fcc
fix: add validation to validate serial nos availability
s-aga-r Jun 29, 2023
1ca3f95
fix: update row qty if `Partial Reservation` is enabled
s-aga-r Jun 30, 2023
eceb7e5
fix: ignore reserved serial nos while getting available serial nos
s-aga-r Jun 30, 2023
fb14ced
fix: add validation to prevent repeat batches
s-aga-r Jun 30, 2023
0db77de
fix(ux): add validation for duplicate Serial No
s-aga-r Jun 30, 2023
2916a27
fix: don't allow to update SRE with delivered stock
s-aga-r Jun 30, 2023
7a1a2e1
fix: ignore reserved serial and batch if reservation based on is not …
s-aga-r Jul 1, 2023
64f12ff
fix(ux): stock un-reservation confirmation before `Update Items`
s-aga-r Jul 1, 2023
cfd9b3a
chore: return list instead os set
s-aga-r Jul 3, 2023
ee61fd8
feat: add field `Delivered Qty` in `Serial and Batch Entry`
s-aga-r Jul 3, 2023
6e2cfb9
feat: option to get SO reserved stock in Delivery Note
s-aga-r Jul 6, 2023
3e0618b
Merge branch 'develop' into SERIAL-AND-BATCH-RESERVATION
s-aga-r Jul 7, 2023
7bcb304
fix: ignore reserved batches while getting available batches
s-aga-r Jul 7, 2023
6c2ada2
chore: `conflicts`
s-aga-r Jul 7, 2023
aa3f5e5
fix: incorrect available qty
s-aga-r Jul 9, 2023
1e94b65
fix: 'str' object has no attribute 'nodes_'
s-aga-r Jul 9, 2023
a31d363
fix: `linter`
s-aga-r Jul 9, 2023
37217f5
fix(ux): hide `Get Items From > Stock Reservation` if Stock Reservati…
s-aga-r Jul 10, 2023
6e2a2a4
fix(ux): add `depends_on` for `Auto Reserve Serial and Batch Nos`
s-aga-r Jul 10, 2023
c6e16a4
fix(ux): hide Stock Reservation field description in submitted SO
s-aga-r Jul 10, 2023
ec89027
fix(ux): confirm before unreserve stock
s-aga-r Jul 10, 2023
05b74c0
feat: option to create DN for reserved stock from SO
s-aga-r Jul 10, 2023
d00c02e
fix: update delivered qty in SRE sb_entries
s-aga-r Jul 10, 2023
b09120c
fix: Delivery Note (Reserved Stock) based on Delivery Date
s-aga-r Jul 11, 2023
c336c66
fix(ux): SO `Update Items` confirmation on `Update` button click
s-aga-r Jul 11, 2023
af6d3d3
feat: add dialog box to select SRE to unreserve
s-aga-r Jul 11, 2023
2233f3a
fix: `ZeroDivisionError` while saving the DN (Reserved Stock)
s-aga-r Jul 12, 2023
147bfc0
fix: don't allow to create Pick List if stock is reserved against SO
s-aga-r Jul 13, 2023
8d0a7f7
fix(ux): hide Create > Pick List button for SO with reserved stock
s-aga-r Jul 13, 2023
15d42da
refactor: map reserved stock by default in DN
s-aga-r Jul 13, 2023
0ef38dd
refactor: code cleanup and comments
s-aga-r Jul 18, 2023
fbdc6e7
fix: don't allow Stock Reservation against SO having Pick List
s-aga-r Jul 19, 2023
1a8994a
refactor: `create_stock_reservation_entries()`
s-aga-r Jul 19, 2023
2df12be
feat: add fields to hold Pick List ref in SRE
s-aga-r Jul 20, 2023
e3fb566
feat: add field `Stock Reserved Qty` in Pick List Item
s-aga-r Jul 20, 2023
7a2aeaa
feat: provision to reserve stock from Pick List against Sales Order
s-aga-r Jul 20, 2023
39fc90f
fix: don't allow to update SRE if created against a Pick List
s-aga-r Jul 20, 2023
3452b7a
fix(ux): confirm before unreserve stock in Pick List
s-aga-r Jul 20, 2023
4eec62b
fix: don't allow to update Pick List having reserved stock
s-aga-r Jul 20, 2023
9145447
fix: circular dependency while cancelling the DN created from Pick Li…
s-aga-r Jul 22, 2023
8bb711d
chore: update `Max Reserve Qty` err msg to be more descriptive
s-aga-r Jul 22, 2023
2d8e21d
refactor: rename field `Reserve Stock on Sales Order Submission`
s-aga-r Jul 24, 2023
d59ce2f
fix: msg on partial reservation if disabled in stock settings
s-aga-r Jul 24, 2023
c70c9c1
chore: add field description for `Enable Stock Reservation`
s-aga-r Jul 24, 2023
74a403e
fix(test): `test_stock_reservation_against_sales_order`
s-aga-r Jul 24, 2023
db9f87e
Merge branch 'develop' into SERIAL-AND-BATCH-RESERVATION
s-aga-r Jul 24, 2023
469baa8
fix(test): `test_stock_reservation_against_sales_order`
s-aga-r Jul 25, 2023
bc876c8
test: add test cases for serial and batch reservation
s-aga-r Jul 25, 2023
55b8a93
fix: batch stock levels qty
s-aga-r Jul 28, 2023
f437f03
refactor: method `get_sre_reserved_qty_for_item_and_warehouse`
s-aga-r Jul 28, 2023
4b90b92
feat: show `Reserved Stock` in item master stock levels
s-aga-r Jul 28, 2023
78a9fa8
Merge branch 'develop' into SERIAL-AND-BATCH-RESERVATION
s-aga-r Jul 28, 2023
48b546d
feat: Reserved Stock Report
s-aga-r Aug 2, 2023
a408aa3
fix(ux): SO stock reservation dialogs width
s-aga-r Aug 6, 2023
75fe4b5
refactor: get previous values from `_doc_before_save` instead of db
s-aga-r Aug 7, 2023
3669845
fix(ux): make `Reservation Based On` read-only if created against Pic…
s-aga-r Aug 8, 2023
902f6e9
feat: option to open `Reserved Stock` report from Sales Order
s-aga-r Aug 10, 2023
460a7b6
fix(ux): Sales Order - Reserve and Unreserve dialog box
s-aga-r Aug 12, 2023
89853d7
fix: decrease SRE Delivered Qty on DN cancel
s-aga-r Aug 26, 2023
53a4bb0
fix(ux): hide `Unreserve` button once reserved stock is delivered
s-aga-r Aug 26, 2023
7d035b7
Merge branch 'develop' into SERIAL-AND-BATCH-RESERVATION
s-aga-r Aug 26, 2023
482158a
chore: `linter`
s-aga-r Aug 26, 2023
64ee8cf
fix(test): `test_reserved_stock_report`
s-aga-r Aug 27, 2023
74a9a9b
test: add test case for DN cancellation
s-aga-r Aug 27, 2023
9963800
chore: rename field `Auto Reserve Stock on Sales Order Submission`
s-aga-r Sep 1, 2023
1a3a906
fix: `Insufficient Stock` error msg
s-aga-r Sep 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,9 @@ def validate_fg_item_for_subcontracting(new_data, is_new):

if has_reserved_stock(parent.doctype, parent.name):
cancel_stock_reservation_entries(parent.doctype, parent.name)
parent.create_stock_reservation_entries()

if parent.per_picked == 0:
parent.create_stock_reservation_entries()


@erpnext.allow_regional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _order(*args, **kwargs):
event = "created"
# Ignore the test ping issued during WooCommerce webhook configuration
# Ref: https://github.com/woocommerce/woocommerce/issues/15642
if frappe.request.data.decode('utf-8').startswith('webhook_id='):
if frappe.request.data.decode("utf-8").startswith("webhook_id="):
return "success"
elif frappe.request and frappe.request.data:
verify_request()
Expand Down
14 changes: 14 additions & 0 deletions erpnext/public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ erpnext.utils.update_child_items = function(opts) {
const cannot_add_row = (typeof opts.cannot_add_row === 'undefined') ? true : opts.cannot_add_row;
const child_docname = (typeof opts.cannot_add_row === 'undefined') ? "items" : opts.child_docname;
const child_meta = frappe.get_meta(`${frm.doc.doctype} Item`);
const has_reserved_stock = opts.has_reserved_stock ? true : false;
const get_precision = (fieldname) => child_meta.fields.find(f => f.fieldname == fieldname).precision;

this.data = frm.doc[opts.child_docname].map((d) => {
Expand Down Expand Up @@ -734,6 +735,17 @@ erpnext.utils.update_child_items = function(opts) {
},
],
primary_action: function() {
if (frm.doctype == "Sales Order" && has_reserved_stock) {
this.hide();
frappe.confirm(
__('The reserved stock will be released when you update items. Are you certain you wish to proceed?'),
() => this.update_items(),
)
} else {
this.update_items();
}
},
update_items: function() {
const trans_items = this.get_values()["trans_items"].filter((item) => !!item.item_code);
frappe.call({
method: 'erpnext.controllers.accounts_controller.update_child_qty_rate',
Expand Down Expand Up @@ -823,6 +835,8 @@ erpnext.utils.map_current_doc = function(opts) {
"target_doc": cur_frm.doc,
"args": opts.args
},
freeze: true,
freeze_message: __("Mapping {0} ...", [opts.source_doctype]),
callback: function(r) {
if(!r.exc) {
var doc = frappe.model.sync(r.message);
Expand Down
Loading