diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index b3949d6..6e13167 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -207,6 +207,14 @@ class HDCase(Model): #XXX get nurse team return data + def empty_line(self,lines=[]): + empty=True + for line in lines: + if line: + empty=False + break + return empty + def onchange_patient(self,context={}): data=context['data'] patient_id=data['patient_id'] @@ -237,6 +245,22 @@ class HDCase(Model): 'type': 'doctor', 'priop': 'owner', }) + + if data['patient_type_id']: + st=get_model("clinic.setting").browse(1) + data['lines']=[] + for pline in st.products: + if data['patient_type_id']==pline.patient_type_id.id: + data['lines'].append({ + 'product_categ_id': pline.product_categ_id.id, + 'product_id': pline.product_id.id, + 'description': pline.description or "", + 'uom_id': pline.uom_id.id, + 'qty': pline.qty or 0, + 'price': pline.price or 0, + 'amount': pline.amount or 0, + }) + return data def onchange_line(self,context={}): @@ -337,6 +361,12 @@ class HDCase(Model): patient=obj.patient_id ptype=patient.type_id + #XXX + shop_type=st.shop_type_id + if not shop_type: + raise Exception("No Patient Type -> Clinic Settings-> RD Shop -> Patient Type") + ptype=shop_type + prod_acc=st.get_product_account for line in obj.lines: if line.reimbursable=='no': @@ -433,10 +463,13 @@ class HDCase(Model): if line.reimbursable=='yes': acc=prod_acc(prod.id,obj.patient_type_id.id) else: + stype=cst.shop_type_id # Pay them self + if not stype: + raise Exception("No Patient Type : Clinic Setting -> RD Shop") if is_credit: - acc=prod_acc(prod.id,obj.patient_type_id.id,'credit') + acc=prod_acc(prod.id,stype.id,'credit') else: - acc=prod_acc(prod.id,obj.patient_type_id.id,'cash') + acc=prod_acc(prod.id,stype.id,'cash') account_id=acc.get("ar_credit_id",None) ar_debit_id=acc.get("ar_debit_id",None) if not account_id: