Open smseidl opened 1 week ago
Can you share your ReportView ?
Sorry - busy weekend. Here's the View you wanted and a sample of one of the Class based ComputationField... all are very similar in definition.
@report_field_register
class TotalCCPaymentField(ComputationField):
name = "sum__paidCC"
calculation_field = "v_pay_dtl__paydetail_amount" # the field we want to compute on
calculation_method = Sum # What method we want, default to Sum
verbose_name = "Total CC Paid $"
# base_q_filters={"v_pay_dtl__parentPayment__type","CC"}
def get_queryset(self):
queryset = self.report_model.objects
# if self.base_q_filters:
queryset = queryset.filter(v_pay_dtl__parentPayment__type="CC")
# if self.base_kwargs_filters:
# queryset = queryset.filter(**self.base_kwargs_filters)
return queryset.order_by()
class ReportPageView(ReportView):
report_title = "Visits by Patient"
report_model = Visit
date_field = "date"
group_by = "patient"
excluded_fields =["documents"]
columns = [
"name",
ComputationField.create(
Count, "id",verbose_name="# Visits",name="sum__value"
),
isPaidField,
ComputationField.create(
Sum, "charge", name="sum__charge", verbose_name="Total Charged $"
),
TotalPaidReportField, #similar to TotalCCPaymentField
TotalCCPaymentField,
TotalCheckPaymentField, #similar to TotalCCPaymentField
TotalEXPPaymentField, #similar to TotalCCPaymentField
]
chart_settings = [
Chart(
"Total Visits",
Chart.BAR,
data_source=["sum__value"],
title_source=["name"],
),
Chart(
"Total Charges $ [PIE]",
Chart.PIE,
data_source=["sum__charge"],
title_source=["name"],
),
Chart(
"Total Unpaid $ [PIE]",
Chart.PIE,
data_source=["count__ispaid"],
title_source=["name"],
)
]
Hi again - sorry for creating so many issues :-( This one seems to be an actual issue. I'm trying to use the
excluded_fields
in my report View to remove some options from the filter form. My model has a bunch of different Foreign Keys that are showing up in the form. I want to limit that some what. When I putdocuments
in theexcluded_fields
list it works, but I am unable to add any of the other without producing an error.Error