From b79cfd015ee07389ffac29b4a77a5859d15e425f Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Fri, 24 Apr 2015 13:48:11 +0700 Subject: [PATCH] prevent forgot enter doctor in hdcase --- .../layouts/clinic_hd_case_form.xml | 2 +- netforce_clinic/models/hd_case.py | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index a351915..8e2e3cc 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -99,7 +99,7 @@ - + diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 057ae8c..de6cc7a 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -101,6 +101,7 @@ class HDCase(Model): lab=0 misc=0 dlz_price=0 + srv=0 mdc=0 for line in obj.lines: amt=line.amount or 0 @@ -122,7 +123,6 @@ class HDCase(Model): else: mdc+=amt mdc_names.append(name or "") - continue #XXX if categ.code=='EPO': name=prod.name or "" name=name.split("-") @@ -133,6 +133,8 @@ class HDCase(Model): fee+=amt*sign elif categ.code=='DLZ': dlz_price+=amt + elif categ.code=='SRV': + dlz_price+=amt elif categ.code=="LAB": if reimbursable_ctx: if reimbursable_ctx==line.reimbursable: @@ -151,6 +153,7 @@ class HDCase(Model): 'lab': lab, 'misc': misc, 'mdc': mdc, + 'srv': srv, 'mdc_name': ','.join([n for n in mdc_names]), 'dlz_id': dlz_id, 'dlz_price': dlz_price, @@ -207,6 +210,7 @@ class HDCase(Model): "dlz_max": fields.Float("DZ Max",function="_get_expense",function_multi=True), "dlz_id": fields.Integer("DZ ID",function="_get_expense",function_multi=True), "mdc": fields.Float("MDC",function="_get_expense",function_multi=True), + "srv": fields.Float("Service",function="_get_expense",function_multi=True), "mdc_name": fields.Float("MDC Name",function="_get_expense",function_multi=True), 'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'), "ref": fields.Char("Ref",search=True), @@ -1084,6 +1088,12 @@ class HDCase(Model): def done(self,ids,context={}): obj=self.browse(ids)[0] + count=0 + for sline in obj.staffs: + if sline.staff_id: + count+=1 + if not count: + raise Exception("Please define doctor for patient %s"%obj.patient_id.name) obj.update_usetime() #FIXME allow user to write sickbed status user_id=get_active_user() @@ -1486,6 +1496,8 @@ class HDCase(Model): st[staff.id]=1 else: raise Exception("Douplicate %s"%staff.name) + if not st: + raise Exception("Please define doctor!") self.check_hct(obj) def approve(self,ids,context={}): @@ -1557,5 +1569,13 @@ class HDCase(Model): }, 'flash': '%s is droped'%dlz.number, } + + def onchange_staff(self,context={}): + data=context['data'] + path=context['path'] + line=get_data_path(data,path,parent=True) + if not line.get('priop'): + line['priop']='owner' + return data HDCase.register()