mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 04:09:11 +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)
|
mylist = re.finditer(regex, criteria.formula, re.MULTILINE | re.DOTALL)
|
||||||
for _dummy1, match in enumerate(mylist):
|
for _dummy1, match in enumerate(mylist):
|
||||||
for _dummy2 in range(0, len(match.groups())):
|
for _dummy2 in range(0, len(match.groups())):
|
||||||
try:
|
param_name = match.group(1)
|
||||||
var = frappe.db.sql(
|
|
||||||
"""
|
variables = frappe.get_all(
|
||||||
SELECT
|
"Supplier Scorecard Variable",
|
||||||
scv.variable_label, scv.description, scv.param_name, scv.path
|
fields=["variable_label", "description", "param_name", "path"],
|
||||||
FROM
|
filters={"param_name": param_name},
|
||||||
`tabSupplier Scorecard Variable` scv
|
limit=1,
|
||||||
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
|
|
||||||
)
|
)
|
||||||
|
if not variables:
|
||||||
|
frappe.throw(_("Unable to find variable: {0}").format(param_name), InvalidFormulaVariable)
|
||||||
|
my_variables.append(variables[0])
|
||||||
|
|
||||||
return my_variables
|
return my_variables
|
||||||
|
|||||||
Reference in New Issue
Block a user