mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 13:49:13 +00:00
fix: (Linter) Write queries using QB/ORM and other minor lines for semgrep to skip
This commit is contained in:
@@ -585,10 +585,20 @@ def get_shipping_rules(quotation=None, cart_settings=None):
|
||||
if quotation.shipping_address_name:
|
||||
country = frappe.db.get_value("Address", quotation.shipping_address_name, "country")
|
||||
if country:
|
||||
shipping_rules = frappe.db.sql_list("""select distinct sr.name
|
||||
from `tabShipping Rule Country` src, `tabShipping Rule` sr
|
||||
where src.country = %s and
|
||||
sr.disabled != 1 and sr.name = src.parent""", country)
|
||||
sr_country = frappe.qb.DocType("Shipping Rule Country")
|
||||
sr = frappe.qb.DocType("Shipping Rule")
|
||||
query = (
|
||||
frappe.qb.from_(sr_country)
|
||||
.join(sr).on(sr.name == sr_country.parent)
|
||||
.select(sr.name)
|
||||
.distinct()
|
||||
.where(
|
||||
(sr_country.country == country)
|
||||
& (sr.disabled != 1)
|
||||
)
|
||||
)
|
||||
result = query.run(as_list=True)
|
||||
shipping_rules = [x[0] for x in result]
|
||||
|
||||
return shipping_rules
|
||||
|
||||
|
||||
Reference in New Issue
Block a user