fix: patch to complete onboarding stpes for existing records

(cherry picked from commit d90ec49241)

# Conflicts:
#	erpnext/patches.txt
This commit is contained in:
Rohit Waghchaure
2026-02-25 17:23:57 +05:30
committed by Mergify
parent cd465e1dbd
commit 941a78e1a8
22 changed files with 68 additions and 70 deletions

View File

@@ -0,0 +1,36 @@
import frappe
from frappe.utils import date_diff, getdate, today
def execute():
steps = frappe.get_all(
"Onboarding Step",
filters={"is_complete": 0},
fields=["name", "action", "reference_document"],
)
if not steps:
return
company_creation = frappe.get_all("Company", fields=["creation"], order_by="creation asc", limit=1)
days_diff = date_diff(getdate(today()), getdate(company_creation[0].creation))
if days_diff > 15:
complete_all_onboarding_steps(steps)
else:
complete_onboarding_steps_if_record_exists(steps)
def complete_all_onboarding_steps(steps):
for step in steps:
frappe.db.set_value("Onboarding Step", step.name, "is_complete", 1, update_modified=False)
def complete_onboarding_steps_if_record_exists(steps):
for step in steps:
if (
step.action == "Create Entry"
and step.reference_document
and frappe.get_all(step.reference_document, limit=1)
):
frappe.db.set_value("Onboarding Step", step.name, "is_complete", 1, update_modified=False)