sort report cycle item
parent
bb21f53e42
commit
d7e1ee21b8
|
@ -6,6 +6,7 @@
|
|||
<field name="ptype_id" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_type" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<field name="sort_by" span="2"/>
|
||||
<group span="6" columns="1">
|
||||
<template>
|
||||
<div>
|
||||
|
|
|
@ -19,6 +19,7 @@ class ReportCycleItem(Model):
|
|||
"ptype_id": fields.Many2One("clinic.patient.type","Patient Type"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
'sort_by': fields.Selection([['hdcase_number','HDCase Number'],['pname','Pateint Name'],['mdc_name','EPO']],'Sort By'),
|
||||
}
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
|
@ -51,6 +52,7 @@ class ReportCycleItem(Model):
|
|||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'ptype_id': ptype_id,
|
||||
'sort_by': 'mdc_name',
|
||||
}
|
||||
print('report.cycle.item.defautls', res)
|
||||
return res
|
||||
|
@ -67,6 +69,7 @@ class ReportCycleItem(Model):
|
|||
print('date_from ', date_from)
|
||||
month=date_from.split("-")[1]
|
||||
cycle_id=None
|
||||
sort_by='mdc_name'
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
month=obj.date_from.split("-")[1]
|
||||
|
@ -76,6 +79,7 @@ class ReportCycleItem(Model):
|
|||
department_id=obj.department_id.id
|
||||
cycle_id=obj.cycle_id.id
|
||||
ptype_id=obj.ptype_id.id
|
||||
sort_by=obj.sort_by or 'mdc_name'
|
||||
# new patient of this month
|
||||
dom=[]
|
||||
dom.append(['date','>=',date_from])
|
||||
|
@ -170,7 +174,7 @@ class ReportCycleItem(Model):
|
|||
'mdc': hdcase.mdc,
|
||||
'hdcase_number': reformat_number(hdcase.number),
|
||||
'hdcase_id': hdcase.id,
|
||||
'mdc_name': hdcase.mdc_name or hdcase.epo,
|
||||
'mdc_name': hdcase.mdc_name or hdcase.epo or '',
|
||||
'iron_name': hdcase.iron_name or '',
|
||||
'fee': abs(hdcase.fee),
|
||||
'dlz_name': hdcase.dlz_name,
|
||||
|
@ -199,6 +203,7 @@ class ReportCycleItem(Model):
|
|||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
company_name+=" ("+branch.name+")"
|
||||
nlines=[]
|
||||
clines=[]
|
||||
index=0
|
||||
old=[]
|
||||
total_fee=0
|
||||
|
@ -260,11 +265,30 @@ class ReportCycleItem(Model):
|
|||
'nfirst_name': cres[i]['first_name'],
|
||||
'ctid': cres[i]['cycle_item_id'],
|
||||
})
|
||||
nlines.append(line)
|
||||
#nlines.append(line)
|
||||
clines.append(line)
|
||||
# if nurse more that cres, should show name of nurses
|
||||
nlines+=more_lines
|
||||
if no==count:
|
||||
epo_items=[{'name': k, 'qty': v} for k,v in epos.items() if k ]
|
||||
#sort item
|
||||
clines=sorted(clines,key=lambda cl: cl[sort_by])
|
||||
no=1
|
||||
index=len(nlines)
|
||||
date_txt=''
|
||||
cseq_txt=''
|
||||
for cline in clines:
|
||||
if cline.get('cseq_txt'):
|
||||
date_txt=cline.get('date_txt')
|
||||
cseq_txt=cline.get('cseq_txt')
|
||||
cline['date_txt']=''
|
||||
cline['cseq_txt']=''
|
||||
cline['no']=no
|
||||
nlines.append(cline)
|
||||
no+=1
|
||||
nlines[index]['date_txt']=date_txt
|
||||
nlines[index]['cseq_txt']=cseq_txt
|
||||
clines=[]
|
||||
nlines.append({
|
||||
'sub': 'show',
|
||||
'is_sub': True,
|
||||
|
|
Loading…
Reference in New Issue