mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
refactor(supplier_scorecard): Replace sql with orm (#55170)
This commit is contained in:
@@ -207,25 +207,16 @@ def make_all_scorecards(docname: str):
|
|||||||
|
|
||||||
while (start_date < todays) and (end_date <= todays):
|
while (start_date < todays) and (end_date <= todays):
|
||||||
# check to make sure there is no scorecard period already created
|
# check to make sure there is no scorecard period already created
|
||||||
scorecards = frappe.db.sql(
|
scorecards = frappe.get_all(
|
||||||
"""
|
"Supplier Scorecard Period",
|
||||||
SELECT
|
fields=["name"],
|
||||||
scp.name
|
filters={
|
||||||
FROM
|
"scorecard": docname,
|
||||||
`tabSupplier Scorecard Period` scp
|
"docstatus": 1,
|
||||||
WHERE
|
"start_date": ["<", end_date],
|
||||||
scp.scorecard = %(sc)s
|
"end_date": [">", start_date],
|
||||||
AND scp.docstatus = 1
|
},
|
||||||
AND (
|
order_by="end_date desc",
|
||||||
(scp.start_date > %(end_date)s
|
|
||||||
AND scp.end_date < %(start_date)s)
|
|
||||||
OR
|
|
||||||
(scp.start_date < %(end_date)s
|
|
||||||
AND scp.end_date > %(start_date)s))
|
|
||||||
ORDER BY
|
|
||||||
scp.end_date DESC""",
|
|
||||||
{"sc": docname, "start_date": start_date, "end_date": end_date},
|
|
||||||
as_dict=1,
|
|
||||||
)
|
)
|
||||||
if len(scorecards) == 0:
|
if len(scorecards) == 0:
|
||||||
period_card = make_supplier_scorecard(docname, None)
|
period_card = make_supplier_scorecard(docname, None)
|
||||||
|
|||||||
Reference in New Issue
Block a user