def clear_mail_flag(modeladmin, request, queryset):
    """
        Clear the email sent flag
        """
    for invoice in queryset:
        if invoice.email_sent:
            invoice.email_sent = False
            invoice.ready_to_send = False
            invoice.save()
            queryset.update(email_sent=False)
