def cleanup_packing_list(doc, parent_items):
 delete_list = []
 for d in doc.get(u'packed_items'):
  if ([d.parent_item, d.parent_detail_docname] not in parent_items):
   delete_list.append(d)
 if (not delete_list):
  return doc
 packed_items = doc.get(u'packed_items')
 doc.set(u'packed_items', [])
 for d in packed_items:
  if (d not in delete_list):
   doc.append(u'packed_items', d)

def cleanup_packing_list ( doc , parent_items ) : delete_list = [ ] for d in doc . get ( u'packed_items' ) : if ( [ d . parent_item , d . parent_detail_docname ] not in parent_items ) : delete_list . append ( d ) if ( not delete_list ) : return doc packed_items = doc . get ( u'packed_items' ) doc . set ( u'packed_items' , [ ] ) for d in packed_items : if ( d not in delete_list ) : doc . append ( u'packed_items' , d )
remove all those child items which are no longer present in main item table .