diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 7771914..608e930 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -74,6 +74,8 @@ class HDCase(Model): res={} user_id=get_active_user() set_active_user(1) + reimbursable_ctx=context.get('reimbursable') + print('reimbursable_ctx ', reimbursable_ctx) for obj in self.browse(ids): dlz_use=0 dlz_max=0 @@ -83,9 +85,9 @@ class HDCase(Model): dz=dlz.dialyzer_id dlz_id=dz.id prod=dz.product_id - #name=dz.name or "" - #name=name.split()[-1] - name=prod.description + name="" + if prod: + name=prod.description or "" dlz_name.append(name) dlz_use+=dlz.use_time or 0 dlz_max+=dlz.max_use_time or 0 @@ -101,7 +103,8 @@ class HDCase(Model): for dline in obj.dialyzers: dlz=dline.dialyzer_id prod=dlz.product_id - dlz_price+=prod.sale_price or 0 + if prod: + dlz_price+=prod.sale_price or 0 for line in obj.lines: amt=line.amount or 0 @@ -121,11 +124,20 @@ class HDCase(Model): elif categ.code=='FEE': fee+=amt*sign elif categ.code=='DLZ': - dlz_price+=prod.sale_price or 0 + if prod: + dlz_price+=prod.sale_price or 0 elif categ.code=="LAB": - lab+=amt + if reimbursable_ctx: + if reimbursable_ctx==line.reimbursable: + lab+=amt + else: + lab+=amt else: - misc+=amt + if reimbursable_ctx: + if reimbursable_ctx==line.reimbursable: + misc+=amt + else: + misc+=amt res[obj.id]={ 'epo': ','.join([n for n in names]), 'fee': fee, @@ -387,6 +399,8 @@ class HDCase(Model): line=get_data_path(data,path,parent=True) product_id=line.get('product_id') prod=get_model("product").browse(product_id) + if not prod: + return data if prod.can_sell: line['reimbursable']='no' else: diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 4ba990a..6c616c8 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -105,7 +105,8 @@ class ReportAccountHDCaseSummary(Model): dom.append(['product_id','=',product_id]) records={} cycles={} - for line in get_model("clinic.hd.case.line").search_browse(dom): + context['reimbursable']=reimbursable + for line in get_model("clinic.hd.case.line").search_browse(dom,context=context): hdcase=line.hd_case_id items={} mdc_name=(hdcase.epo or "").split("-") diff --git a/netforce_clinic/templates/report_account_hd_case_summary.hbs b/netforce_clinic/templates/report_account_hd_case_summary.hbs index 3f94c74..431a8db 100644 --- a/netforce_clinic/templates/report_account_hd_case_summary.hbs +++ b/netforce_clinic/templates/report_account_hd_case_summary.hbs @@ -38,7 +38,7 @@