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