From b9e122edf19f5ea3b62d9af5f5a65e77f4fb9825 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Wed, 12 Apr 2017 14:58:35 +0700 Subject: [PATCH] qty summary by product name --- .../models/report_account_hd_case_summary.py | 19 +++++++++++++++++++ .../report_account_hd_case_summary.hbs | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 2878059..10a103c 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -321,6 +321,25 @@ class ReportAccountHDCaseSummary(Model): else: data['title']='Report - No Claim' data['title']='' #XXX + + categs={} + for line in lines: + if line.get('hdcase_id'): + hdcase_id=line['hdcase_id'] + hdcase=get_model("clinic.hd.case").browse(hdcase_id) + for line2 in hdcase.lines: + prod=line2.product_id + categ=line2.product_categ_id + if categ.code=='EPO': + categs.setdefault(prod.description, 0) + categs[prod.description]+=line2.qty or 0 + + data['categ_lines']=[] + for categ, qty in categs.items(): + data['categ_lines'].append({ + 'name': categ, + 'qty': qty, + }) return data def onchange_date(self,context={}): diff --git a/netforce_clinic/templates/report_account_hd_case_summary.hbs b/netforce_clinic/templates/report_account_hd_case_summary.hbs index 3d36ab0..c1071bf 100644 --- a/netforce_clinic/templates/report_account_hd_case_summary.hbs +++ b/netforce_clinic/templates/report_account_hd_case_summary.hbs @@ -8,7 +8,15 @@

From {{date_from}} To {{date_to}}

+ +

+ {{#each categ_lines}} + {{name}}: {{qty}}     + {{/each}} +

+ +