diff --git a/netforce_clinic/models/report_medical_detail.py b/netforce_clinic/models/report_medical_detail.py index c6f280b..45fbaf0 100644 --- a/netforce_clinic/models/report_medical_detail.py +++ b/netforce_clinic/models/report_medical_detail.py @@ -30,7 +30,7 @@ class ReportMedicalDetail(Model): date_from=defaults.get('date_from','%s-%s-01'%(year,month)) date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day)) categ_id=defaults.get('categ_id',None) - report_type=defaults.get('report_type',"completed") + report_type=defaults.get('report_type') or "completed" if not categ_id: categ_ids=get_model("product.categ").search([['code','=','MDC']]) if categ_ids: @@ -67,7 +67,6 @@ class ReportMedicalDetail(Model): 'product_id': product_id, 'report_type': report_type, } - print('report_type ', report_type) return res def get_report_data(self,ids,context={}): @@ -76,7 +75,6 @@ class ReportMedicalDetail(Model): defaults=self.default_get(context=context) time_start=defaults.get("date_from") time_stop=defaults.get("date_to") - prod_categ_id=defaults.get("prod_categ_id") branch_id=defaults.get("branch_id") department_id=defaults.get("department_id") product_id=defaults.get('product_id') @@ -84,7 +82,6 @@ class ReportMedicalDetail(Model): report_type=defaults.get('report_type','completed') if ids: obj=self.browse(ids)[0] - prod_categ_id=obj.prod_categ_id.id product_id=obj.product_id.id types=obj.types branch_id=obj.branch_id.id @@ -97,10 +94,16 @@ class ReportMedicalDetail(Model): ['hd_case_id.date','>=',time_start], ['hd_case_id.date','<=',time_stop], ] + shop_dom=[ + ['shop_id.date','>=',time_start], + ['shop_id.date','<=',time_stop], + ] if branch_id: dom.append(['hd_case_id.branch_id','=',branch_id]) + shop_dom.append(['shop_id.branch_id','=',branch_id]) if department_id: dom.append(['hd_case_id.department_id','=',department_id]) + shop_dom.append(['shop_id.department_id','=',department_id]) st=get_model("clinic.setting").browse(1) ct_ids=[] for categ in st.product_categ_view: @@ -137,6 +140,26 @@ class ReportMedicalDetail(Model): 'hname': hdcase.number, }) total_qty+=qty + + for line in get_model("clinic.shop.line").search_browse(shop_dom): + shop=line.shop_id + patient=shop.patient_id + department=shop.department_id + qty=line.qty or 0 + lines.append({ + 'date': shop.date or '', + 'tname': patient.type_id.name or '', + 'pname': patient.name or '', + 'qty': qty, + 'cname': 'RD Shop', + 'cseq': 999, + 'dpt_name': department.name, + 'hid': shop.id, + 'hname': shop.number, + 'is_shop': True, + }) + total_qty+=qty + sub_name='' if department_id: dpt=get_model("clinic.department").browse(department_id) @@ -146,8 +169,9 @@ class ReportMedicalDetail(Model): sub_name="(%s)" % branch.name or "" company_id=get_active_company() company=get_model("company").browse(company_id) + lines=sorted(lines,key=lambda x: (x['date'],x['cseq'])) no=1 - for line in sorted(lines,key=lambda x: (x['date'],x['cseq'])): + for line in lines: line['no']=no no+=1 data={ diff --git a/netforce_clinic/models/report_medical_summary.py b/netforce_clinic/models/report_medical_summary.py index 66bfd0e..dd30a9a 100644 --- a/netforce_clinic/models/report_medical_summary.py +++ b/netforce_clinic/models/report_medical_summary.py @@ -79,11 +79,16 @@ class ReportMedicalSummary(Model): time_start=obj.date_from time_stop=obj.date_to report_type=obj.report_type or "completed" - print('report_type ---> ', report_type) products={} patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")} dom=[] + shop_dom=[ + ['date','>=',time_start], + ['date','<=',time_stop], + ['department_id','=',department_id], + ['branch_id','=',branch_id], + ] dom.append(['type','=','stock']) dom.append(['report_visible','=',True]) st=get_model("clinic.setting").browse(1) @@ -136,6 +141,15 @@ class ReportMedicalSummary(Model): else: products[prod_code][patient_type_id]['qty']+=line.qty + # add qty from rd shop + for shop in get_model("clinic.shop").search_browse(shop_dom): + for line in shop.lines: + prod=line.product_id + categ=line.categ_id + if categ and categ.id not in list(categ_ids): + continue + products[prod.code][themself_id]['qty']+=line.qty + lines=[] limit_char=25 titles=[{'name': 'ชื่อยา'}] diff --git a/netforce_clinic/templates/report_medical_detail.hbs b/netforce_clinic/templates/report_medical_detail.hbs index eae423d..74891ff 100644 --- a/netforce_clinic/templates/report_medical_detail.hbs +++ b/netforce_clinic/templates/report_medical_detail.hbs @@ -7,11 +7,11 @@ # - HDCase# Date + Cycle + Number Patient Type - Cycle Department Qty @@ -20,13 +20,17 @@ {{#each lines}} {{no}} - - {{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}} - {{date}} + {{cname}} + + {{#if is_shop}} + {{view "link" string=hname action="clinic_shop" action_options="mode=form" active_id=hid}} + {{else}} + {{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}} + {{/if}} + {{pname}} {{tname}} - {{cname}} {{dpt_name}} {{qty}} diff --git a/netforce_clinic/templates/report_medical_summary.hbs b/netforce_clinic/templates/report_medical_summary.hbs index b8ba80c..f1f751a 100644 --- a/netforce_clinic/templates/report_medical_summary.hbs +++ b/netforce_clinic/templates/report_medical_summary.hbs @@ -21,7 +21,7 @@ {{#each sub_lines}} - {{qty}} + {{qty}} {{/each}}