mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
fix: patch to complete onboarding stpes for existing records
(cherry picked from commit d90ec49241)
# Conflicts:
# erpnext/patches.txt
This commit is contained in:
committed by
Mergify
parent
cd465e1dbd
commit
941a78e1a8
@@ -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)
|
||||
Reference in New Issue
Block a user