when i am doing auto repeat to task which having child task
parent task is marked as Open but child task is same its not marked as open
Dependent Tasks – this one is still same neither status is setting open nor id is chaning
when i am doing auto repeat to task which having child task
parent task is marked as Open but child task is same its not marked as open
Dependent Tasks – this one is still same neither status is setting open nor id is chaning
Hi @Pkolhetkar,
You’re right — currently, Auto Repeat in ERPNext duplicates only the main (parent) Task, and it doesn’t automatically update or recreate the status of child/dependent tasks. This is expected behavior since dependencies aren’t re-evaluated during Auto Repeat.
To handle this, you might consider:
Let me know if you’d like help writing a custom script for this.
i was writing server script like this but no changes on child task
if doc.get(“auto_repeat”):
# Open parent task
doc.status = “Open”
doc.save(ignore_permissions=True)
repeat_doc = frappe.get_doc("Auto Repeat", doc.auto_repeat)
original_task_name = repeat_doc.reference_document
# Get all children of the original task
original_children = frappe.get_all("Task", filters={"parent_task": original_task_name}, fields=["name"])
for child in original_children:
old_child = frappe.get_doc("Task", child.name)
# Create new child manually (not a copy)
new_child = frappe.new_doc("Task")
new_child.subject = old_child.subject
new_child.project = old_child.project
new_child.priority = old_child.priority
new_child.weight = old_child.weight
new_child.type = old_child.type
new_child.description = old_child.get("description", "")
new_child.parent_task = doc.name
new_child.status = "Open"
# Do NOT copy dependencies
new_child.set("dependencies", [])
# Save new child task
new_child.insert(ignore_permissions=True)
# Log task created
frappe.msgprint(f" Created new child: <b>{new_child.name}</b>")
Server Script Type:
doc.save()
again inside the script — it’ll cause recursion.Auto Repeat Context:
doc.auto_repeat
is present on the new task, but that’s not always guaranteed at the time of After Insert
. Use logging or frappe.msgprint
to confirm.if doc.auto_repeat:
# Re-open the parent task if needed
doc.db_set("status", "Open")
# Fetch the Auto Repeat document
repeat_doc = frappe.get_doc("Auto Repeat", doc.auto_repeat)
original_task_name = repeat_doc.reference_document
# Get all child tasks of the original task
original_children = frappe.get_all("Task", filters={"parent_task": original_task_name}, fields=["name"])
for child in original_children:
old_child = frappe.get_doc("Task", child.name)
# Create new child manually
new_child = frappe.new_doc("Task")
new_child.subject = old_child.subject
new_child.project = old_child.project
new_child.priority = old_child.priority
new_child.weight = old_child.weight
new_child.type = old_child.type
new_child.description = old_child.description
new_child.parent_task = doc.name
new_child.status = "Open"
new_child.insert(ignore_permissions=True)
frappe.msgprint(f"✅ Created child task: <b>{new_child.name}</b>")
parent_task
.frappe.msgprint()
or frappe.log_error()
to debug if it’s not triggering.If your child tasks are still showing as “Completed” even after inserting them manually with status = "Open"
, here are the most likely causes and how to fix them:
You must use After Insert
.
"Before Save"
can cause recursive or unintended behavior if doc.save()
or changes are made.After Insert
ensures doc.name
is available and no recursion occurs. Recommended:
Doctype: Task
Script Type: After Insert
status
Is Being Overridden Laterstatus = "Open"
, ERPNext might have workflows or hooks that set it back to “Completed”. Add a log right after insert:
frappe.msgprint(f"Inserted Task: {new_child.name} with status {new_child.status}")
Also add a log inside
Before Save
or validate
of Task DocType:
To confirm if some other logic is changing the status.
Check that this line is not copying “Completed”:
# old_child.status might be "Completed"
new_child.status = "Open" # ✅ make sure this is hardcoded
If you mistakenly did:
new_child.status = old_child.status # ❌ This will copy "Completed"
Then the child will be created with “Completed” again.
ERPNext workflows can automatically set the status based on state transitions.
Go to:
ERPNext > Settings > Workflow
"Completed"
automatically.if doc.auto_repeat:
# Mark new Task as Open
doc.db_set("status", "Open")
# Fetch the Auto Repeat document
repeat_doc = frappe.get_doc("Auto Repeat", doc.auto_repeat)
original_task_name = repeat_doc.reference_document
# Get all child tasks of the original task
original_children = frappe.get_all("Task", filters={"parent_task": original_task_name}, fields=["name"])
for child in original_children:
old_child = frappe.get_doc("Task", child.name)
# Create new child manually
new_child = frappe.new_doc("Task")
new_child.subject = old_child.subject
new_child.project = old_child.project
new_child.priority = old_child.priority
new_child.weight = old_child.weight
new_child.type = old_child.type
new_child.description = old_child.description
new_child.parent_task = doc.name
new_child.status = "Open" # ✅ Make sure this is set explicitly
new_child.insert(ignore_permissions=True)
frappe.msgprint(f"✅ Created child task: <b>{new_child.name}</b> with status {new_child.status}")
new_child.status = "Draft"
or some custom value and check in DB.frappe.db.set_value("Task", new_child.name, "status", "Open")
after insert.Let me know if you want help debugging a particular child task (e.g., its name). I can help trace exactly why its status ends up as “Completed.”