conv_bal
watcha.h 2015-04-23 16:30:20 +07:00
parent e5cd180a9c
commit 62c044f070
6 changed files with 37 additions and 15 deletions

View File

@ -103,6 +103,15 @@ class CycleItem(Model):
def validate(self,ids,context={}):
obj=self.browse(ids)[0]
#prevent duplicate nurse
ns={}
for line in obj.lines:
nurse=line.nurse_id
if not ns.get(nurse.id):
ns[nurse.id]=1
else:
raise Exception("Duplicate %s"%nurse.name)
for hdcase in obj.hd_cases:
state=hdcase.state
if state=='cancelled':

View File

@ -1475,6 +1475,16 @@ class HDCase(Model):
self.function_store(ids)
super().write(ids,vals,**kw)
obj=self.browse(ids)[0]
# prevent duplicate doctor
print('obj.state ', obj.state)
if obj.state in ('waiting_payment', 'paid'):
st={}
for lstaff in obj.staffs:
staff=lstaff.staff_id
if not st.get(staff.id):
st[staff.id]=1
else:
raise Exception("Douplicate %s"%staff.name)
self.check_hct(obj)
def approve(self,ids,context={}):

View File

@ -311,18 +311,19 @@ class LaborCost(Model):
if hd_case.state not in ('waiting_payment','paid'):
continue
staffs=hd_case.staffs
if not staffs and dwalkin:
staff=dwalkin
staff_total[staff.id]={
doctor_id=hd_case.doctor_id
if not doctor_id and dwalkin:
if not staff_total.get(dwalkin.id):
staff_total[dwalkin.id]={
'base': 0,
'type': staff.type,
'categ_id': staff.categ_id.id,
'level_id': staff.level_id.id,
'type': dwalkin.type,
'categ_id': dwalkin.categ_id.id,
'level_id': dwalkin.level_id.id,
'qty': 0,
}
base=cost_per_case
staff_total[staff.id]['base']=base
staff_total[staff.id]['qty']+=1
staff_total[dwalkin.id]['base']=base
staff_total[dwalkin.id]['qty']+=1
else:
for ps in staffs:
staff=ps.staff_id or dwalkin

View File

@ -313,7 +313,7 @@ class MatchingHDCase(Model):
if date_from==date_to:
date=date_from
data={
'lines': lines,
'lines': sorted(lines,key=lambda x: x.get('date')),
'date_from': date_from,
'date_to': date_to,
'date': date,

View File

@ -187,6 +187,7 @@ class ReportLaborCost(Model):
'branch_id': department.branch_id.id,
}
for hdcase in citem.hd_cases:
if hdcase.state in ('waiting_payment','paid'):
ndata[dpt_name]['hdcases'].update({hdcase.id})
total_amount=0
for categ_name,vals in ctdata.items():

View File

@ -56,8 +56,9 @@ class ReportThaiWHTCertif(Model):
else:
if contact_type!=comp.contact_type:
raise Exception("Different WHT contact types for same payment")
print('sequence ', comp.sequence)
exp_code=comp.sequence or "5"
exp_code=exp_code.replace(".","_")
print('sequence ', exp_code)
#if comp.exp_type=="salary":
#exp_code="1"
#elif comp.exp_type=="commission":