mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
feat: adding warehouse filter for gross profit report (#33397)
Co-authored-by: ruthra kumar <ruthra@erpnext.com>
This commit is contained in:
@@ -50,6 +50,20 @@ frappe.query_reports["Gross Profit"] = {
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Sales Person"
|
"options": "Sales Person"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "warehouse",
|
||||||
|
"label": __("Warehouse"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Warehouse",
|
||||||
|
"get_query": function () {
|
||||||
|
var company = frappe.query_report.get_filter_value('company');
|
||||||
|
return {
|
||||||
|
filters: [
|
||||||
|
["Warehouse", "company", "=", company]
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"tree": true,
|
"tree": true,
|
||||||
"name_field": "parent",
|
"name_field": "parent",
|
||||||
|
|||||||
@@ -775,6 +775,13 @@ class GrossProfitGenerator(object):
|
|||||||
if self.filters.get("item_code"):
|
if self.filters.get("item_code"):
|
||||||
conditions += " and `tabSales Invoice Item`.item_code = %(item_code)s"
|
conditions += " and `tabSales Invoice Item`.item_code = %(item_code)s"
|
||||||
|
|
||||||
|
if self.filters.get("warehouse"):
|
||||||
|
warehouse_details = frappe.db.get_value(
|
||||||
|
"Warehouse", self.filters.get("warehouse"), ["lft", "rgt"], as_dict=1
|
||||||
|
)
|
||||||
|
if warehouse_details:
|
||||||
|
conditions += f" and `tabSales Invoice Item`.warehouse in (select name from `tabWarehouse` wh where wh.lft >= {warehouse_details.lft} and wh.rgt <= {warehouse_details.rgt} and warehouse = wh.name)"
|
||||||
|
|
||||||
self.si_list = frappe.db.sql(
|
self.si_list = frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
select
|
select
|
||||||
|
|||||||
Reference in New Issue
Block a user