@@ -666,6 +666,16 @@ def validate_item(self, item_code, row):
666666 validate_is_stock_item ,
667667 )
668668
669+ def validate_serial_batch_items ():
670+ has_batch_no , has_serial_no = frappe .get_value (
671+ "Item" , item_code , ["has_batch_no" , "has_serial_no" ]
672+ )
673+ if row .use_serial_batch_fields :
674+ if has_batch_no and not row .batch_no :
675+ raise frappe .ValidationError (_ ("Please enter Batch No" ))
676+ if has_serial_no and not row .serial_no :
677+ raise frappe .ValidationError (_ ("Please enter Serial No" ))
678+
669679 # using try except to catch all validation msgs and display together
670680
671681 try :
@@ -674,12 +684,13 @@ def validate_item(self, item_code, row):
674684 # end of life and stock item
675685 validate_end_of_life (item_code , item .end_of_life , item .disabled )
676686 validate_is_stock_item (item_code , item .is_stock_item )
687+ validate_serial_batch_items ()
677688
678689 # docstatus should be < 2
679690 validate_cancelled_item (item_code , item .docstatus )
680691
681692 except Exception as e :
682- self .validation_messages .append (_ ("Row #" ) + " " + ("%d: " % (row .idx )) + cstr (e ))
693+ self .validation_messages .append (_ ("Row #" ) + ("%d: " % (row .idx )) + cstr (e ))
683694
684695 def validate_reserved_stock (self ) -> None :
685696 """Raises an exception if there is any reserved stock for the items in the Stock Reconciliation."""
0 commit comments