@@ -19,6 +19,71 @@ $.extend(erpnext, {
1919 return currency_list ;
2020 } ,
2121
22+ toggle_serial_batch_fields ( frm ) {
23+ let hide_fields = cint ( frappe . user_defaults ?. enable_serial_and_batch_no_for_item ) === 0 ? 1 : 0 ;
24+ let fields = [ "serial_and_batch_bundle" , "use_serial_batch_fields" , "serial_no" , "batch_no" ] ;
25+
26+ if (
27+ [
28+ "Stock Entry" ,
29+ "Purchase Receipt" ,
30+ "Purchase Invoice" ,
31+ "Stock Reconciliation" ,
32+ "Subcontracting Receipt" ,
33+ ] . includes ( frm . doc . doctype )
34+ ) {
35+ fields . push ( "add_serial_batch_bundle" ) ;
36+ }
37+
38+ if ( [ "Stock Reconciliation" ] . includes ( frm . doc . doctype ) ) {
39+ fields . push ( "reconcile_all_serial_batch" ) ;
40+ }
41+
42+ if ( [ "Sales Invoice" , "Delivery Note" , "Pick List" ] . includes ( frm . doc . doctype ) ) {
43+ fields . push ( "pick_serial_and_batch" ) ;
44+ }
45+
46+ if ( [ "Purchase Receipt" , "Purchase Invoice" , "Subcontracting Receipt" ] . includes ( frm . doc . doctype ) ) {
47+ fields . push ( "add_serial_batch_for_rejected_qty" , "rejected_serial_and_batch_bundle" ) ;
48+ }
49+
50+ let child_name = "items" ;
51+ if ( frm . doc . doctype === "Pick List" ) {
52+ child_name = "locations" ;
53+ }
54+
55+ if ( frm . doc . doctype === "Asset Capitalization" ) {
56+ child_name = "stock_items" ;
57+ }
58+
59+ fields . forEach ( ( field ) => {
60+ frm . fields_dict [ child_name ] . grid . update_docfield_property ( field , "hidden" , hide_fields ) ;
61+
62+ frm . fields_dict [ child_name ] . grid . update_docfield_property (
63+ field ,
64+ "in_list_view" ,
65+ hide_fields ? 0 : 1
66+ ) ;
67+
68+ if (
69+ frm . doc . doctype === "Subcontracting Receipt" &&
70+ ! [ "add_serial_batch_for_rejected_qty" , "rejected_serial_and_batch_bundle" ] . includes ( field )
71+ ) {
72+ frm . fields_dict [ "supplied_items" ] . grid . update_docfield_property ( field , "hidden" , hide_fields ) ;
73+
74+ frm . fields_dict [ "supplied_items" ] . grid . update_docfield_property (
75+ field ,
76+ "in_list_view" ,
77+ hide_fields ? 0 : 1
78+ ) ;
79+
80+ frm . fields_dict [ "supplied_items" ] . grid . reset_grid ( ) ;
81+ }
82+ } ) ;
83+
84+ frm . fields_dict [ child_name ] . grid . reset_grid ( ) ;
85+ } ,
86+
2287 toggle_naming_series : function ( ) {
2388 if (
2489 cur_frm &&
0 commit comments