diff --git a/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.js b/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.js index 497cae15..bc888330 100644 --- a/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.js +++ b/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.js @@ -8,48 +8,38 @@ frappe.query_reports["Catch Log Statistics"] = { fieldname: "from_year", fieldtype: "Int", label: __("From Year"), - mandatory: 0, - wildcard_filter: 0, default: moment().year() - 1, }, { fieldname: "to_year", fieldtype: "Int", label: __("To Year"), - mandatory: 0, - wildcard_filter: 0, default: moment().year(), }, { fieldname: "water_body", - fieldtype: "Link", - options: "Water Body", + fieldtype: "MultiSelectList", label: __("Water Body"), - mandatory: 0, - wildcard_filter: 0, + get_data: (txt) => frappe.db.get_link_options("Water Body", txt), }, { fieldname: "fish_species", - fieldtype: "Link", + fieldtype: "MultiSelectList", label: __("Fish Species"), - options: "Fish Species", + get_data: (txt) => frappe.db.get_link_options("Fish Species", txt), }, { fieldname: "organization", fieldtype: "Link", options: "Organization", label: __("Organization"), - mandatory: 0, - wildcard_filter: 0, default: frappe.defaults.get_user_default("Organization"), }, { fieldname: "fishing_area", - fieldtype: "Link", - options: "Fishing Area", + fieldtype: "MultiSelectList", label: __("Fishing Area"), - mandatory: 0, - wildcard_filter: 0, + get_data: (txt) => frappe.db.get_link_options("Fishing Area", txt), }, ], }; diff --git a/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.py b/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.py index eeffe4ad..d11beeae 100644 --- a/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.py +++ b/landa/water_body_management/report/catch_log_statistics/catch_log_statistics.py @@ -146,14 +146,22 @@ def filter_and_group(query, entry: Table, child_table: Table, qb_filters: List[C def get_qb_filters(filters, entry, child_table): filters["workflow_state"] = "Approved" - fish_species = filters.pop("fish_species", None) + fish_species = filters.pop("fish_species", []) + water_body = filters.pop("water_body", []) + fishing_area = filters.pop("fishing_area", []) from_year = filters.pop("from_year", None) to_year = filters.pop("to_year", None) qb_filters = [entry[key] == value for key, value in filters.items()] if fish_species: - qb_filters.append(child_table.fish_species == fish_species) + qb_filters.append(child_table.fish_species.isin(fish_species)) + + if water_body: + qb_filters.append(entry.water_body.isin(water_body)) + + if fishing_area: + qb_filters.append(entry.fishing_area.isin(fishing_area)) if from_year: qb_filters.append(entry.year >= from_year)