diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 4307af2..310542d 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -71,40 +71,38 @@ class ReportAccountHDCaseSummary(Model): reimbursable=obj.reimbursable cycle_id=obj.cycle_id.id dom=[ - ['date','>=', date_from], - ['date','<=', date_to], - ['patient_id.walkin','=','no'], + ['hd_case_id.date','>=', date_from], + ['hd_case_id.date','<=', date_to], + ['hd_case_id.patient_id.walkin','=','no'], ] if ptype_id: - dom.append(['patient_type_id','=',ptype_id]) + dom.append(['hd_case_id.patient_type_id','=',ptype_id]) if branch_id: - dom.append(['branch_id','=',branch_id]) + dom.append(['hd_case_id.branch_id','=',branch_id]) if department_id: - dom.append(['department_id','=',department_id]) + dom.append(['hd_case_id.department_id','=',department_id]) if cycle_id: - dom.append(['cycle_id','=',cycle_id]) - if reimbursable=='yes': - dom.append(['state','in',['waiting_payment']]) - elif reimbursable=='no': - dom.append(['state','in',['paid']]) + dom.append(['hd_case_id.cycle_id','=',cycle_id]) + if reimbursable: + dom.append(['reimbursable','=',reimbursable]) else: - dom.append(['state','in',['completed','waiting_payment','paid']]) + dom.append(['hd_case_id.state','in',['completed','waiting_payment','paid']]) lines=[] cycles={} - for hdcase in get_model("clinic.hd.case").search_browse(dom): + for line in get_model("clinic.hd.case.line").search_browse(dom): + hdcase=line.hd_case_id items={} mdc_name=(hdcase.epo or "").split("-") if mdc_name: mdc_name=mdc_name[0].title() - for line in hdcase.lines: - amt=line.amount or 0 - categ=line.product_categ_id - code=(categ.code or "").lower() - if not code in items.keys(): - items[code]=[] - items[code].append({ - 'amount': amt, - }) + amt=line.amount or 0 + categ=line.product_categ_id + code=(categ.code or "").lower() + if not code in items.keys(): + items[code]=[] + items[code].append({ + 'amount': amt, + }) pm_number=','.join([pm.number for pm in hdcase.payments if pm.number]) inv_number="" inv_ref=""