changeset 1939:22d052f3537d

health : task #13620: Close the appointment when the related evaluation has been done
author Luis Falcon <falcon@gnu.org>
date Mon, 18 May 2015 12:56:22 +0100
parents e138a6a2858c
children 8c8b8f5e0c93
files tryton/health/health.py
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health/health.py
+++ b/tryton/health/health.py
@@ -4441,6 +4441,9 @@
     def end_evaluation(cls, evaluations):
         evaluation_id = evaluations[0]
 
+        Appointment = Pool().get('gnuhealth.appointment')
+        patient_app=[]
+        
         # Change the state of the evaluation to "Done"
 
         signing_hp = HealthProfessional().get_health_professional()
@@ -4448,8 +4451,17 @@
         cls.write(evaluations, {
             'state': 'done',
             'signed_by': signing_hp,
-        })
-            
+            })
+        
+        # If there is an appointment associated to this evaluation
+        # set it to state "Done"
+        
+        if evaluations[0].evaluation_date:
+            patient_app.append(evaluations[0].evaluation_date)
+            Appointment.write(patient_app, {
+                'state': 'done',
+                })
+
     @staticmethod
     def default_healthprof():
         return HealthProfessional().get_health_professional()