mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
refactor(buying): replace sql query by orm (#55153)
This commit is contained in:
@@ -73,22 +73,16 @@ def _get_variables(criteria):
|
||||
mylist = re.finditer(regex, criteria.formula, re.MULTILINE | re.DOTALL)
|
||||
for _dummy1, match in enumerate(mylist):
|
||||
for _dummy2 in range(0, len(match.groups())):
|
||||
try:
|
||||
var = frappe.db.sql(
|
||||
"""
|
||||
SELECT
|
||||
scv.variable_label, scv.description, scv.param_name, scv.path
|
||||
FROM
|
||||
`tabSupplier Scorecard Variable` scv
|
||||
WHERE
|
||||
param_name=%(param)s""",
|
||||
{"param": match.group(1)},
|
||||
as_dict=1,
|
||||
)[0]
|
||||
my_variables.append(var)
|
||||
except Exception:
|
||||
frappe.throw(
|
||||
_("Unable to find variable:") + " " + str(match.group(1)), InvalidFormulaVariable
|
||||
)
|
||||
param_name = match.group(1)
|
||||
|
||||
variables = frappe.get_all(
|
||||
"Supplier Scorecard Variable",
|
||||
fields=["variable_label", "description", "param_name", "path"],
|
||||
filters={"param_name": param_name},
|
||||
limit=1,
|
||||
)
|
||||
if not variables:
|
||||
frappe.throw(_("Unable to find variable: {0}").format(param_name), InvalidFormulaVariable)
|
||||
my_variables.append(variables[0])
|
||||
|
||||
return my_variables
|
||||
|
||||
Reference in New Issue
Block a user