@@ -970,6 +970,80 @@ def test_nagative_stock_for_batch(self):
970
970
971
971
self .assertRaises (frappe .ValidationError , ste .submit )
972
972
973
+ def test_quality_check_for_scrap_item (self ):
974
+ from erpnext .manufacturing .doctype .work_order .work_order import (
975
+ make_stock_entry as _make_stock_entry ,
976
+ )
977
+
978
+ scrap_item = "_Test Scrap Item 1"
979
+ make_item (scrap_item , {"is_stock_item" : 1 , "is_purchase_item" : 0 })
980
+
981
+ bom_name = frappe .db .get_value ("BOM Scrap Item" , {"docstatus" : 1 }, "parent" )
982
+ production_item = frappe .db .get_value ("BOM" , bom_name , "item" )
983
+
984
+ work_order = frappe .new_doc ("Work Order" )
985
+ work_order .production_item = production_item
986
+ work_order .update (
987
+ {
988
+ "company" : "_Test Company" ,
989
+ "fg_warehouse" : "_Test Warehouse 1 - _TC" ,
990
+ "production_item" : production_item ,
991
+ "bom_no" : bom_name ,
992
+ "qty" : 1.0 ,
993
+ "stock_uom" : frappe .db .get_value ("Item" , production_item , "stock_uom" ),
994
+ "skip_transfer" : 1 ,
995
+ }
996
+ )
997
+
998
+ work_order .get_items_and_operations_from_bom ()
999
+ work_order .submit ()
1000
+
1001
+ stock_entry = frappe .get_doc (_make_stock_entry (work_order .name , "Manufacture" , 1 ))
1002
+ for row in stock_entry .items :
1003
+ if row .s_warehouse :
1004
+ make_stock_entry (
1005
+ item_code = row .item_code ,
1006
+ target = row .s_warehouse ,
1007
+ qty = row .qty ,
1008
+ basic_rate = row .basic_rate or 100 ,
1009
+ )
1010
+
1011
+ if row .is_scrap_item :
1012
+ row .item_code = scrap_item
1013
+ row .uom = frappe .db .get_value ("Item" , scrap_item , "stock_uom" )
1014
+ row .stock_uom = frappe .db .get_value ("Item" , scrap_item , "stock_uom" )
1015
+
1016
+ stock_entry .inspection_required = 1
1017
+ stock_entry .save ()
1018
+
1019
+ self .assertTrue ([row .item_code for row in stock_entry .items if row .is_scrap_item ])
1020
+
1021
+ for row in stock_entry .items :
1022
+ if not row .is_scrap_item :
1023
+ qc = frappe .get_doc (
1024
+ {
1025
+ "doctype" : "Quality Inspection" ,
1026
+ "reference_name" : stock_entry .name ,
1027
+ "inspected_by" : "Administrator" ,
1028
+ "reference_type" : "Stock Entry" ,
1029
+ "inspection_type" : "In Process" ,
1030
+ "status" : "Accepted" ,
1031
+ "sample_size" : 1 ,
1032
+ "item_code" : row .item_code ,
1033
+ }
1034
+ )
1035
+
1036
+ qc_name = qc .submit ()
1037
+ row .quality_inspection = qc_name
1038
+
1039
+ stock_entry .reload ()
1040
+ stock_entry .submit ()
1041
+ for row in stock_entry .items :
1042
+ if row .is_scrap_item :
1043
+ self .assertFalse (row .quality_inspection )
1044
+ else :
1045
+ self .assertTrue (row .quality_inspection )
1046
+
973
1047
def test_quality_check (self ):
974
1048
item_code = "_Test Item For QC"
975
1049
if not frappe .db .exists ("Item" , item_code ):
0 commit comments