def invalidate_invoice(obj_invoice):
 if (not obj_invoice.is_valid):
  return HttpResponseBadRequest(_('The sale associated with this invoice has already been invalidated.'))
 obj_invoice.is_valid = False
 obj_invoice.save()
 message = _('Invoice number {0} has been invalidated.').format(obj_invoice.id)
 return JsonResponse({'message': message})

def invalidate_invoice ( obj_invoice ) : if ( not obj_invoice . is_valid ) : return HttpResponseBadRequest ( _ ( 'The sale associated with this invoice has already been invalidated.' ) ) obj_invoice . is_valid = False obj_invoice . save ( ) message = _ ( 'Invoice number {0} has been invalidated.' ) . format ( obj_invoice . id ) return JsonResponse ( { 'message' : message } )
this method invalidate the sale against the invoice number .