Auto repeat issue- child task status is not set Open

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:

  1. Custom Script to update child task status when parent is repeated.
  2. Creating a custom app or server script to clone the full task structure (including dependencies) with proper status set.

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>")

:mag: Common Issues to Check:

  1. Server Script Type:

    • Make sure your Server Script type is “Before Save” or “After Insert” on the Task doctype.
    • If you’re using “Before Save”, avoid using doc.save() again inside the script — it’ll cause recursion.
    • Recommended: Use “After Insert” type.
  2. Auto Repeat Context:

    • ERPNext Auto Repeat creates a new Task based on the original.
    • Your logic assumes that the 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.

:white_check_mark: Fixed Version of the Script (Type: After Insert, Doctype: Task):

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>")

:white_check_mark: Checklist:

  • Script Type: After Insert
  • Doctype: Task
  • Make sure the original task has proper child tasks linked via parent_task.
  • Auto Repeat is set correctly and working.
  • Use frappe.msgprint() or frappe.log_error() to debug if it’s not triggering.

@Rahul123 still child task is no change(it should come Open but still completed showing)

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:


:white_check_mark: Checklist to Fix the Problem

1. Double-check the Server Script Type

  • You must use After Insert.

    • "Before Save" can cause recursive or unintended behavior if doc.save() or changes are made.
    • Using After Insert ensures doc.name is available and no recursion occurs.

:white_check_mark: Recommended:

Doctype: Task  
Script Type: After Insert  

2. Check If the status Is Being Overridden Later

  • Even if you insert a child with status = "Open", ERPNext might have workflows or hooks that set it back to “Completed”.

:white_check_mark: Add a log right after insert:

frappe.msgprint(f"Inserted Task: {new_child.name} with status {new_child.status}")

:white_check_mark: Also add a log inside Before Save or validate of Task DocType:
To confirm if some other logic is changing the status.


3. Make Sure You’re Not Copying the Old Child’s 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.


4. Check if There’s a Workflow Applied

ERPNext workflows can automatically set the status based on state transitions.

:white_check_mark: Go to:

ERPNext > Settings > Workflow

  • Check if “Task” has a workflow that sets "Completed" automatically.

5. Final Safe Version of Script

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}")

:mag: Still Not Working?

  1. Temporarily set new_child.status = "Draft" or some custom value and check in DB.
  2. Use frappe.db.set_value("Task", new_child.name, "status", "Open") after insert.
  3. Use Developer > “Reload DocType” and clear cache to eliminate stale scripts.
  4. Test with a non-auto-repeat task manually.

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.”