class ProductSales(ReportView):
report_title = _("Product Sales")
report_description = _("Given a typical 'Sale Item' model, this report demonstrate a total of product sold. "
"With a bar and a pie charts.")
report_model = SalesTransaction
date_field = "date"
group_by = "product"
columns = [
"name",
ComputationField.create(
method=Sum,
field="value",
name="value__sum",
verbose_name="Total sold $",
is_summable=True,
),
]
# Charts
chart_settings = [
Chart(
"Total sold $",
Chart.BAR,
data_source=["value__sum"],
title_source=["name"],
),
]