Index: /WAeUP_SRP/base/Accommodation.py
===================================================================
--- /WAeUP_SRP/base/Accommodation.py	(revision 3042)
+++ /WAeUP_SRP/base/Accommodation.py	(revision 3043)
@@ -38,9 +38,11 @@
         generate the free Bedslist.
         """
-        freelist = self.portal_accommodation
+        bed_list = self.portal_accommodation
         l = self.portal_catalog({'meta_type': "AccoHall"})
         halls = []
         generated = []
         generated.append('"Bed","BedType","Student"' % vars())
+        modyfied = []
+        modyfied.append('"Bed","BedType","Student"' % vars())
         beds_generated = []
         for h in l:
@@ -52,13 +54,19 @@
             hall_gen['name'] = hall.Title
             count = 0
+            modyfied_count = 0
             reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',hall_doc.reserved_rooms)
                                      if r]
             #for block in range(1,int(hall_doc.nr_of_blocks)+1):
             # for block in 'ABCDEFGHIJ'[:int(hall_doc.nr_of_blocks)]:
-            if set(hall_doc.blocks_for_female).intersection(set(hall_doc.blocks_for_male)):
+            blocks_for_female = getattr(hall_doc,'blocks_for_female',[])
+            blocks_for_male = getattr(hall_doc,'blocks_for_male',[])
+            beds_for_fresh = getattr(hall_doc,'beds_for_fresh',[])
+            beds_for_pre = getattr(hall_doc,'beds_for_pre',[])
+            beds_for_final = getattr(hall_doc,'beds_for_final',[])
+            if set(blocks_for_female).intersection(set(blocks_for_male)):
                 return self.accommodation.acco_folder_view(beds_generated=beds_generated)
-            for block in hall_doc.blocks_for_female + hall_doc.blocks_for_male:
+            for block in blocks_for_female + blocks_for_male:
                 sex = 'male'
-                if block in hall_doc.blocks_for_female:
+                if block in blocks_for_female:
                     sex = 'female'
                 for floor in range(1,int(hall_doc.nr_of_floors)+1):
@@ -71,9 +79,9 @@
                             elif hall_doc.special_handling and not hall_doc.special_handling.startswith("no"):
                                 bt = hall_doc.special_handling
-                            elif bed in hall_doc.beds_for_fresh:
+                            elif bed in beds_for_fresh:
                                 bt = 'fr'
-                            elif bed in hall_doc.beds_for_pre:
+                            elif bed in beds_for_pre:
                                 bt = 'pr'
-                            elif bed in hall_doc.beds_for_final:
+                            elif bed in beds_for_final:
                                 bt = 'fi'
                             if hall_doc.special_handling.startswith("no_"):
@@ -86,21 +94,23 @@
                             d['sort_id'] = getattr(hall_doc,'sort_id',0)
                             d['hall'] = hall.getId()
-                            d['student'] = NOT_OCCUPIED
-                            try:
-                                #freelist.addRecord(bed = uid, bed_type = bt,hall = hall.getId())
-                                freelist.addRecord(**d)
+                            bed_record = bed_list.getRecordByKey(uid)
+                            if bed_record is None:
+                                d['student'] = NOT_OCCUPIED
+                                bed_list.addRecord(**d)
                                 count +=1
                                 generated.append('"%(uid)s","%(bt)s"' % vars())
-                            except ValueError:
-                                #freelist.modifyRecord(bed = uid, bed_type = bt,hall =hall.getId())
-                                #freelist.modifyRecord(**d)
+                            elif bed_record.bed_type != bt:
+                                bed_list.modifyRecord(**d)
+                                modyfied.append('"%(uid)s","%(bt)s"' % vars())
+                                modyfied_count += 1
                                 pass
             hall_gen['count']= count
+            hall_gen['modyfied_count']= modyfied_count
             beds_generated.append(hall_gen)
         current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
         open("%s/import/bedlist_%s.csv" % (i_home,current),"w+").write('\n'.join(generated))
+        open("%s/import/bedlist_modyfied_%s.csv" % (i_home,current),"w+").write('\n'.join(modyfied))
         return self.accommodation.acco_folder_view(beds_generated=beds_generated)
-
-###)
+    ###)
 
     security.declareProtected(ModifyPortalContent,"importReservedBeds")###(
Index: /WAeUP_SRP/base/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/base/WAeUPTables.py	(revision 3042)
+++ /WAeUP_SRP/base/WAeUPTables.py	(revision 3043)
@@ -482,4 +482,5 @@
     name = "portal_accommodation"
     key = "bed"
+    not_occupied = NOT_OCCUPIED
     def __init__(self,name=None):
         if name ==  None:
@@ -487,5 +488,5 @@
         WAeUPTable.__init__(self, name)
 
-    def searchAndReserveBed(self, student_id,bed_type):
+    def searchAndReserveBed(self, student_id,bed_type): ###(
         #records = self.searchResults({'student' : student_id})
         #import pdb;pdb.set_trace()
@@ -504,4 +505,5 @@
         s_logger.info('%s reserved bed %s' % (student_id,rec.bed))
         return 1,rec.bed
+    ###)
 
 
Index: /WAeUP_SRP/base/skins/waeup_accommodation/acco_folder_view.pt
===================================================================
--- /WAeUP_SRP/base/skins/waeup_accommodation/acco_folder_view.pt	(revision 3042)
+++ /WAeUP_SRP/base/skins/waeup_accommodation/acco_folder_view.pt	(revision 3043)
@@ -22,9 +22,11 @@
         <tr>
           <th width="200px">Hall Name</th>
-          <th>New Beds Generated</th>
+          <th>Beds Generated</th>
+          <th>Beds Modyfied</th>
         </tr>
         <tr tal:repeat="hall beds_generated">
           <td tal:content="hall/name"></td>
           <td tal:content="hall/count"></td>
+          <td tal:content="hall/modyfied_count"></td>
         </tr>
       </table>
Index: /WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py
===================================================================
--- /WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py	(revision 3042)
+++ /WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py	(revision 3043)
@@ -44,5 +44,5 @@
         return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
     logger.info('Bed status %s of %s has changed to %s' % (allocated_bed.bed_type,student_id,status))
-    beds.modifyRecord(bed=allocated_bed.bed,student='')
+    beds.modifyRecord(bed=allocated_bed.bed,student=beds.not_occupied)
     logger.info('Bed %s released' % (allocated_bed.bed))
     code,bed = beds.searchAndReserveBed(student_id,status)
