Deleting a Project which is linked to Sales Order

Hi- I created a Sales Order, and from it, I accidentally created 2 Projects instead of 1.
Now, when I try deleting the extra project, I get a message:
“Cannot delete or cancel because Project PR0002 is linked with Sales Order SO-00004”

I tried un-linking the Project from the Sales Order by selecting a blank Sales Order, or by selecting another Sales Order in the Project’s edit page. This removed the Project from the Sales Order edit’s page, but did not remove the Sales Order from the Project’s edit page.

The only way to delete a linked Project is to delete the Sales Order. And I do not want to do that. Any help in this regard will be much appreciated.

I tried on ERPNext: v10.0.6 (master), Frappe Framework: v10.0.7 (master). I was able to delete a project linked to sale order. The only warning I got is “Cannot delete or cancel because Project X is linked with Task Y”. After I’ve delete the task, the project was deletable.

Try to delete both links, sale order and project in PR0002 and SO-00004. Then delete PR0002.

Hey thanks for the quick reply. There is no option to remove a Project from Sales Order edit page, because there is no Projects field. Also, my ERPNext is slightly older.

ERPNext: v9.2.23 (master)

Frappe Framework: v9.2.24 (master)

Any guidance on how to update it? I tried ‘bench update --reset’ but no dice. I get error:

INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Updating b3bc4a6…56e2f75
error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/”, line 40, in cli
File “/usr/local/lib/python2.7/dist-packages/click/”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/”, line 34, in update
File “/home/frappe/.bench/bench/”, line 256, in update_bench
exec_cmd(“git pull”, cwd=cwd)
File “/home/frappe/.bench/bench/”, line 140, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull

Any help will be much appreicated.

I managed to start the update process.

  1. Be logged in as the frappe user. su frappe (and enter password)
  2. Go to the home directory of the frappe user. cd ~
  3. Then go to a ‘./.bench’ directory. cd ./.bench
  4. Then run git stash
  5. Then return to the frappe-bench directory and run ‘bench update --reset’

Hope this helps somebody.

Hurrah! Able to delete the Project linked to a Sales Order. Thanks for your help, Rene_Mailloux!!

1 Like

OK- premature celebrations! There is now a new problem. I cant cancel (to delete) the Sales Order against which I had deleted the Project. I am able to cancel/delete all new Sales Orders against which Projects were created/deleted. Its just this old one, which was created before the update. The error message I am getting when I try to cancel the Sales Order SO-00004:

Not found
Project SO-00004 not found
Did not cancel
The resource you are looking for is not available

Note that it says Project SO-00004. This Project may have existed at some point in time, but is not there any more. Would I need to delete this Sales Order from the DB?

Any help will be much appreciated.

Hey- it looked like I made an error in my repeating steap. Can you test whether its happening on your end or not:

  1. Create a sales order.
  2. Make a project from the sales order.
  3. Save the project
  4. Try deleting the project.

Can you tell me if you are also getting an error?



Here is what I did.

  1. Create a Sales Order with Ctrl+B.
  2. Fill, save and submit the Sales Order.
  3. Make button then Project.
  4. Save the new Project.
  5. Menu button, delete then Yes to confirm.
  6. Impossible to delete because Task.
  7. Click the Task.
  8. Menu, Delete, Yes. (Back to Project)
  9. Menu, Delete, Yes. (Back to Sales Order)

If you have access to the DB. Go in tabSales Oder and delete all refences to the project in your sales order SO-00004. Maybe you will have to delete all SO-00004 references in tabProject for the project you want to delete. Then go in ERPNext to cancel SO-00004. Don’t delete the entire record.

If this problem append again. Try to delete the first project created instead of the second one. Its an issue in ERPNext. When the second project is created, the first project number is overwritten in project field of sales order. I don’t know if its better to limit to 1 project or to remove the link in Sales Order doctype. Do you want to report this issue?