code: def delete_records_safely_by_xml_id(env, xml_ids):
      
      for xml_id in xml_ids:
          logger.debug('Deleting record for XML-ID %s', xml_id)
          try:
              with env.cr.savepoint():
                  env.ref(xml_id).exists().unlink()
          except Exception as e:
              logger.error('Error deleting XML-ID %s: %s', xml_id, repr(e))
docs: This removes in the safest possible way the records whose XML-IDs are
      passed as argument.
  
      :param xml_ids: List of XML-ID string identifiers of the records to remove.