print pdf

conv_bal
watcha.h 2015-05-27 16:51:38 +07:00
parent a4787dc4d3
commit d60b077e5d
8 changed files with 44 additions and 14 deletions

View File

@ -4,5 +4,6 @@
<field name="model">clinic.report.cycle.item</field> <field name="model">clinic.report.cycle.item</field>
<field name="report_template">report_cycle_item</field> <field name="report_template">report_cycle_item</field>
<field name="report_template_xls">report_cycle_item</field> <field name="report_template_xls">report_cycle_item</field>
<field name="export_pdf">1</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
</action> </action>

View File

@ -4,5 +4,6 @@
<field name="model">clinic.report.hd.case.summary</field> <field name="model">clinic.report.hd.case.summary</field>
<field name="report_template">report_hd_case_summary</field> <field name="report_template">report_hd_case_summary</field>
<field name="report_template_xls">report_hd_case_summary</field> <field name="report_template_xls">report_hd_case_summary</field>
<field name="export_pdf">1</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
</action> </action>

View File

@ -37,7 +37,7 @@
<item string="Visit Board" action="clinic_visit_board"/> <item string="Visit Board" action="clinic_visit_board"/>
<divider/> <divider/>
<item string="New Visit" action="clinic_visit" action_options="mode=form"/> <item string="New Visit" action="clinic_visit" action_options="mode=form"/>
<item string="Make An Appointment" action="clinic_make_apt"/> <!--<item string="Make An Appointment" action="clinic_make_apt"/>-->
</item> </item>
<item string="HD Cases" perm="clinic_hdcase"> <item string="HD Cases" perm="clinic_hdcase">
<item string="HD Cases" action="clinic_hd_case"/> <item string="HD Cases" action="clinic_hd_case"/>

View File

@ -5,7 +5,4 @@
<field name="hdcase_type" required="1" span="2"/> <field name="hdcase_type" required="1" span="2"/>
<field name="branch_id" onchange="onchange_branch" span="2"/> <field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/> <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<foot>
<button string="Export PDF" method="export_pdf"/>
</foot>
</form> </form>

View File

@ -260,6 +260,11 @@ class ReportHDCaseSummary(Model):
elif branch_id: elif branch_id:
branch=get_model("clinic.branch").browse(branch_id) branch=get_model("clinic.branch").browse(branch_id)
sub_name="(%s)" % branch.name or "" sub_name="(%s)" % branch.name or ""
medical_lines=medicals['lines']
medical_titles=medicals['titles']
plines=medicals['plines']
prod_titles=medicals['prod_titles']
date_print=time.strftime("%m/%d/%Y %H:%M:%S")
data={ data={
'hdcase_type': hdcase_type, 'hdcase_type': hdcase_type,
'branch_id': branch_id, 'branch_id': branch_id,
@ -267,13 +272,16 @@ class ReportHDCaseSummary(Model):
'date_from': date_from, 'date_from': date_from,
'date_to': date_to, 'date_to': date_to,
'date': date, 'date': date,
'date_print': date_print,
'month': month_str, 'month': month_str,
'year': year, 'year': year,
'lines': lines, 'lines': lines,
'recent_patients': get_model("clinic.report.recent.patient").get_report_data(ids=[],context=context)['lines'], 'recent_patients': get_model("clinic.report.recent.patient").get_report_data(ids=[],context=context)['lines'],
'resign_patients': get_model("clinic.report.discontinue.patient").get_report_data(ids=[],context=context)['lines'], 'resign_patients': get_model("clinic.report.discontinue.patient").get_report_data(ids=[],context=context)['lines'],
'medicals': medicals['lines'], 'medicals': medical_lines,
'titles': medicals['titles'], 'titles': medical_titles,
'plines': plines,
'prod_titles': prod_titles,
'company_name': '%s %s'% (company.name or "", sub_name), 'company_name': '%s %s'% (company.name or "", sub_name),
'parent_company_name': company.parent_id.name or "", 'parent_company_name': company.parent_id.name or "",
} }

View File

@ -131,26 +131,42 @@ class ReportMedicalSummary(Model):
products[prod_code][patient_type_id]['qty']+=line.qty products[prod_code][patient_type_id]['qty']+=line.qty
lines=[] lines=[]
limit=25 limit_char=25
titles=[{'name': 'ชื่อยา'}] titles=[{'name': 'ชื่อยา'}]
prod_titles={}
for patient_type_id,type_name in sorted(patient_types.items(), key=lambda x: x[0]): for patient_type_id,type_name in sorted(patient_types.items(), key=lambda x: x[0]):
prod_titles.update({patient_type_id: type_name})
titles.append({ titles.append({
'name':type_name, 'name':type_name,
}) })
for prod, records in products.items():
prod_name=records[patient_type_id]['name'] or ""
prod_name_org=records[patient_type_id]['name'] or ""
prod_name=len(prod_name) > limit and '%s...' %prod_name[0:limit] or prod_name
plines=[]
def rzero(n):
if not n:
return ''
n="{0:,.0f}".format(n)
return n
for prod, prod_vals in products.items():
count=1 count=1
total=0.0 total=0.0
sub_lines=[] sub_lines=[]
all_ptypes="" all_ptypes=""
prod_id=None prod_id=None
pvals={}
for patient_type_id,type_name in sorted(patient_types.items(), key=lambda x: x[0]): for patient_type_id,type_name in sorted(patient_types.items(), key=lambda x: x[0]):
all_ptypes+="%s,"%patient_type_id all_ptypes+="%s,"%patient_type_id
qty=records[patient_type_id]['qty'] or 0 qty=prod_vals[patient_type_id]['qty'] or 0
prod_id=records[patient_type_id]['prod_id']
prod_id=prod_vals[patient_type_id]['prod_id']
prod_name=prod_vals[patient_type_id]['name'] or ""
prod_name_org=prod_vals[patient_type_id]['name'] or ""
prod_name=len(prod_name) > limit_char and '%s...' %prod_name[0:limit_char] or prod_name
pvals.update({
'prod_name': prod_name,
patient_type_id : rzero(qty),
})
line={ line={
'prod_name': prod_name, 'prod_name': prod_name,
'prod_name_org': prod_name_org, 'prod_name_org': prod_name_org,
@ -177,11 +193,14 @@ class ReportMedicalSummary(Model):
}) })
line['sub_lines']=sub_lines line['sub_lines']=sub_lines
lines.append(line) lines.append(line)
pvals[999]=int(total)
plines.append(pvals)
for line in lines: for line in lines:
st="" st=""
for x in line['sub_lines']: for x in line['sub_lines']:
st+='%s'%(x['types']) st+='%s'%(x['types'])
titles.append({'name':'รวม'}) titles.append({'name':'รวม'})
company_id=get_active_company() company_id=get_active_company()
@ -203,11 +222,15 @@ class ReportMedicalSummary(Model):
elif branch_id: elif branch_id:
branch=get_model("clinic.branch").browse(branch_id) branch=get_model("clinic.branch").browse(branch_id)
sub_name="(%s)" % branch.name or "" sub_name="(%s)" % branch.name or ""
plines=sorted(plines,key=lambda x:x['prod_name'])
data={ data={
'company_name': '%s %s' % (company.name or "", sub_name), 'company_name': '%s %s' % (company.name or "", sub_name),
'parent_company_name': company.parent_id.name or "", 'parent_company_name': company.parent_id.name or "",
'titles': titles, 'titles': titles,
'lines': lines, 'lines': lines,
'plines': plines,
'prod_titles': prod_titles,
'month': month_str, 'month': month_str,
'year': year, 'year': year,
'report_type': report_type, 'report_type': report_type,