@@ -1333,6 +1333,14 @@ def _validate_checklist_branch(pos_profile):
13331333def get_checklist (pos_profile , checklist_type ):
13341334 _validate_checklist_branch (pos_profile )
13351335
1336+ has_checklist = frappe .db .exists ("URY Checklist Item" , {"parent" : pos_profile })
1337+ if not has_checklist :
1338+ return {
1339+ "items" : [],
1340+ "log_name" : None ,
1341+ "log_status" : "Complete" ,
1342+ }
1343+
13361344 configured_items = frappe .get_all (
13371345 "URY Checklist Item" ,
13381346 fields = ["item_label" , "applies_to" , "is_mandatory" ],
@@ -1356,6 +1364,8 @@ def get_checklist(pos_profile, checklist_type):
13561364 if existing_log :
13571365 log_name = existing_log [0 ].name
13581366 log_status = existing_log [0 ].status
1367+ elif not configured_items :
1368+ log_status = "Complete"
13591369
13601370 return {
13611371 "items" : configured_items ,
@@ -1368,6 +1378,13 @@ def get_checklist(pos_profile, checklist_type):
13681378def submit_checklist (pos_profile , checklist_type , items , pos_opening_entry = None ):
13691379 _validate_checklist_branch (pos_profile )
13701380
1381+ has_checklist = frappe .db .exists ("URY Checklist Item" , {"parent" : pos_profile })
1382+ if not has_checklist :
1383+ return {
1384+ "status" : "Complete" ,
1385+ "name" : None ,
1386+ }
1387+
13711388 items = json .loads (items )
13721389
13731390 configured_items = frappe .get_all (
@@ -1376,6 +1393,12 @@ def submit_checklist(pos_profile, checklist_type, items, pos_opening_entry=None)
13761393 filters = {"parent" : pos_profile , "applies_to" : ["in" , [checklist_type , "Both" ]]},
13771394 parent_doctype = "POS Profile" ,
13781395 )
1396+
1397+ if not configured_items :
1398+ return {
1399+ "status" : "Complete" ,
1400+ "name" : None ,
1401+ }
13791402 mandatory_by_label = {row .item_label : row .is_mandatory for row in configured_items }
13801403
13811404 existing_log = frappe .get_all (
0 commit comments