Can a Server Script create a Project and automatically generate tasks from a Project Template?

I’m trying to automate Project creation using a Server Script in ERPNext.

I know that when a Project is created manually and a Project Template is selected, ERPNext automatically creates all the tasks from that template, along with the planned dates and other related logic.

My question is:

  • Is it possible to create a new Project through a Server Script and have ERPNext automatically generate the tasks from the selected Project Template?

  • Is there a built-in method or function that invokes the same logic used by the standard “Create Project from Template” flow?

  • Or would I need to manually recreate the task creation logic in my script?

I’m hoping to reuse ERPNext’s existing implementation rather than duplicating the code, especially since it already handles task creation and scheduling.

Has anyone implemented this or knows the recommended approach?

Hi
When a Project is saved with a project_template, ERPNext already has server-side logic that copies the template tasks, calculates planned dates, preserves dependencies, and creates the project tasks. This is the same logic used when creating a Project through the UI.
If your server script creates a Project document and sets the template before inserting it, the standard document lifecycle should execute the existing logic.
Assuming you’re using the standard Project DocType and haven’t bypassed document events (for example with db_insert()), ERPNext should invoke its normal hooks and generate the tasks.