mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
refactor(territory_wise_sales):replace sql with orm (#55177)
This commit is contained in:
@@ -104,30 +104,21 @@ def get_data(filters=None):
|
||||
|
||||
|
||||
def get_opportunities(filters):
|
||||
conditions = ""
|
||||
orm_filters = {}
|
||||
|
||||
if filters.get("transaction_date"):
|
||||
conditions = " WHERE transaction_date between {} and {}".format(
|
||||
frappe.db.escape(filters["transaction_date"][0]),
|
||||
frappe.db.escape(filters["transaction_date"][1]),
|
||||
orm_filters["transaction_date"] = [
|
||||
"between",
|
||||
[filters["transaction_date"][0], filters["transaction_date"][1]],
|
||||
]
|
||||
|
||||
if filters.get("company"):
|
||||
orm_filters["company"] = filters["company"]
|
||||
|
||||
return frappe.get_all(
|
||||
"Opportunity", fields=["name", "territory", "opportunity_amount"], filters=orm_filters
|
||||
)
|
||||
|
||||
if filters.company:
|
||||
if conditions:
|
||||
conditions += " AND"
|
||||
else:
|
||||
conditions += " WHERE"
|
||||
conditions += " company = %(company)s"
|
||||
|
||||
return frappe.db.sql(
|
||||
f"""
|
||||
SELECT name, territory, opportunity_amount
|
||||
FROM `tabOpportunity` {conditions}
|
||||
""",
|
||||
filters,
|
||||
as_dict=1,
|
||||
) # nosec
|
||||
|
||||
|
||||
def get_quotations(opportunities):
|
||||
if not opportunities:
|
||||
|
||||
Reference in New Issue
Block a user