From 12064ca9b4cf8b3e72ef647034cdd673f8ab18f9 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Sat, 10 Jun 2017 22:51:39 +0700 Subject: [PATCH] create patient.move after patient created --- netforce_clinic/models/patient.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 239b348..e457a3b 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -293,9 +293,9 @@ class Patient(Model): def create(self, vals,**kw): if 'card_no' in vals.keys(): self.check_idcard(vals.get("card_type",""),vals['card_no']) - obj_id=super().create(vals,**kw) - self.function_store([obj_id]) - obj=self.browse(obj_id) + new_id=super().create(vals,**kw) + self.function_store([new_id]) + obj=self.browse(new_id) partner_id=obj.partner_id if not partner_id: partner_name='%s %s'%(obj.first_name or "",obj.last_name or "") # XXX @@ -327,7 +327,16 @@ class Patient(Model): obj.write({ 'partner_id': partner_id, }) - return obj_id + + ########### patient.move + get_model("clinic.patient.move").create({ + 'patient_id': new_id, + 'location_from_id': obj.department_id.id, + 'location_to_id': obj.department_id.id, + 'state': 'new', + }) + ########### + return new_id def delete(self,ids,context={}): partner_ids=[]