Luxury electric car maker Tesla has won a court battle in Massachusetts so it can sell cars direct to buyers without going through a traditional dealer.