Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/accommodation.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/accommodation.py	(revision 15704)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/accommodation.py	(revision 15705)
@@ -138,10 +138,12 @@
             available_beds = [
                 entry for entry in entries if entry.owner == NOT_OCCUPIED]
+            desired_hostel = self.__parent__.desired_hostel
+            if desired_hostel and desired_hostel != 'no':
+                # Filter desired hostel beds
+                filtered_beds = [bed for bed in available_beds
+                                 if bed.bed_id.startswith(desired_hostel)]
+                available_beds = filtered_beds
             if available_beds:
-                new_bed = students_utils.selectBed(
-                    available_beds, self.__parent__.desired_hostel)
-                if new_bed is None:
-                    return False, _(
-                        'There is no free bed in your desired hostel.')
+                new_bed = students_utils.selectBed(available_beds)
                 new_bed.bookBed(student.student_id)
             else:
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 15704)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 15705)
@@ -2340,4 +2340,20 @@
     notice = ''
     with_ac = True
+    with_bedselection = True
+
+    def getAvailableBeds(self, acc_details, desired_hostel):
+        """Get a list of all available beds.
+        """
+        cat = queryUtility(ICatalog, name='beds_catalog', default=None)
+        entries = cat.searchResults(
+            bed_type=(acc_details['bt'],acc_details['bt']))
+        available_beds = [
+            entry for entry in entries if entry.owner == NOT_OCCUPIED]
+        if desired_hostel and desired_hostel != 'no':
+            # Filter desired hostel beds
+            filtered_beds = [bed for bed in available_beds
+                             if bed.bed_id.startswith(desired_hostel)]
+            return filtered_beds
+        return available_beds
 
     def update(self, SUBMIT=None):
@@ -2381,19 +2397,9 @@
             # else search for other available beds
             manual = False
-            entries = cat.searchResults(
-                bed_type=(acc_details['bt'],acc_details['bt']))
-            available_beds = [
-                entry for entry in entries if entry.owner == NOT_OCCUPIED]
+            available_beds = self.getAvailableBeds(
+                acc_details, self.context.desired_hostel)
             if available_beds:
                 students_utils = getUtility(IStudentsUtils)
-                bed = students_utils.selectBed(
-                    available_beds, self.context.desired_hostel)
-                if bed is None:
-                    self.flash(_(
-                        'There is no free bed in your desired hostel. '
-                        'Please try another hostel.'),
-                        type="warning")
-                    self.redirect(self.url(self.context))
-                    return
+                bed = students_utils.selectBed(available_beds)
                 # Safety belt for paranoids: Does this bed really exist
                 # in portal?
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 15704)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 15705)
@@ -301,4 +301,5 @@
         constraint=validate_email,
         )
+
     phone = PhoneNumber(
         title = _(u'Phone'),
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 15704)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 15705)
@@ -3360,5 +3360,5 @@
         self.browser.getControl("Create bed ticket").click()
         # Hostel 2 has only a bed for women.
-        self.assertTrue('There is no free bed in your desired hostel'
+        self.assertTrue('There is no free bed in your category regular_male_fr.'
             in self.browser.contents)
         self.browser.getControl(name="hostel").value = ['hall-1']
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 15704)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 15705)
@@ -665,5 +665,5 @@
         return
 
-    def selectBed(self, available_beds, desired_hostel=None):
+    def selectBed(self, available_beds):
         """Select a bed from a filtered list of available beds.
         In the base configuration beds are sorted by the sort id
@@ -673,11 +673,4 @@
         sorted_beds = sorted(available_beds,
                 key=lambda bed: 1000 * bed.__parent__.sort_id + bed.bed_number)
-        if desired_hostel and desired_hostel != 'no':
-            # Filter desired hostel beds
-            filtered_beds = [bed for bed in sorted_beds
-                             if bed.bed_id.startswith(desired_hostel)]
-            if not filtered_beds:
-                return
-            return filtered_beds[0]
         return sorted_beds[0]
 
