 
       # Updates `all`, `none` and `master_selection` when necessary.
       $scope.$watch 'n_selected_VMs', (n) ->
-        $scope.all = (VMs.length is n)
+        $scope.all = (xo.byTypes.VM?.length is n)
         $scope.none = (n is 0)
 
         # When the master checkbox is clicked from indeterminate

          true

      $scope.selectVMs = (sieve) ->
        if (sieve is true) or (sieve is false)
          $scope.n_selected_VMs = if sieve then VMs.length else 0
          selected_VMs[VM.UUID] = sieve for VM in VMs

      controller: 'TreeCtrl'
      template: require './view'
  .controller 'TreeCtrl', ($scope, modal, $upload, xo, dateFilter, deleteVmsModal, notify) ->
    Object.defineProperties($scope, {
      xo: { get: -> xo.byTypes.xo?[0] },
      pools: { get: -> xo.byTypes.pool },
