Index: /WAeUP_SRP/trunk/profiles/default/types/StudentAccommodation.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/StudentAccommodation.xml	(revision 1134)
+++ /WAeUP_SRP/trunk/profiles/default/types/StudentAccommodation.xml	(revision 1135)
@@ -38,3 +38,8 @@
   <permission value="Modify portal content"/>
  </action>
+ <action title="Change Bed" action_id="change_bed" category="object"
+    condition_expr="" url_expr="string:${object_url}/change_bed"
+    visible="True">
+  <permission value="Modify portal content"/>
+ </action>
 </object>
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/change_bed.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/change_bed.py	(revision 1134)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/change_bed.py	(revision 1135)
@@ -10,10 +10,11 @@
 # $Id$
 """
-return Info about the current Student
+relocate to a new bed if allocated bed is wrong
 """
 import logging
-logger = logging.getLogger('Student.Clearance.Info')
+logger = logging.getLogger('Student.Accommodation.change_bed')
 
 request = context.REQUEST
+redirect = request.RESPONSE.redirect
 mtool = context.portal_membership
 wf = context.portal_workflow
@@ -24,7 +25,40 @@
 if mtool.isAnonymousUser():
     return None
-info = {}
+students = context.portal_url.getPortalObject().campus.students
 beds = context.portal_accommodation
 studs = context.students_catalog
+student_id = context.getStudentId()
+
+if student_id is not None:
+    logger.info('"%s", "requests bed_change for", "%s"' % (member_id,student_id))
+    info = context.getAccommodationInfo(student_id)
+    res = beds(student=student_id)
+    if len(res) == 0:
+        logger.info('"%s", "no bed found"' % (student_id))
+        redirect("%s/%s" % (students.absolute_url(),student_id))
+    allocated_bed = res[0]
+    status = info['student_status']
+    student = student_id
+    if allocated_bed.bed_type == status:
+        logger.info('"%s", "correct bed allocated","%s"' % (student_id,status))
+        redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
+    logger.info('"%s", "change bed", "%s/%s"' % (student_id,allocated_bed.bed_type,status))
+    beds.modifyRecord(bed=allocated_bed.bed,student='')
+    code,bed = beds.searchAndReserveBed(student_id,status)
+    if code > 0:
+        #from Products.zdb import set_trace; set_trace()
+        d = {}
+        d['bed'] = bed
+        d['student_status'] = status
+        acco_info = context.waeup_tool.getAccommodationInfo(bed)
+        d['acco_maint_code'] = acco_info.get('maintenance_code')
+        d['acco_maint_fee'] = acco_info.get('maintenance_fee')
+        acco_doc = info['acco_doc']
+        acco_doc.edit(mapping=d)
+        redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
+    logger.info('"%s", "new bed allocation failed","%s"' % (student_id,code))
+    redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
+        
+info = {}
 records = [r for r in beds() if  r.student]
 list = []
