Try ERPNext Buy Support Partners Foundation

Help needed customizing a status of Opportunity

Hello community.

Came across a small use case where I need to have a new “status” to a Opportunity. Which is “Assigned”.

Status of an Opportunity needs to change to “Assigned” once the opportunity has been assigned. And perhaps show “Assigned” in its list view.

Any help? I’m willing to go into the opportunity.js because built-in Workflow isn’t making this happen for me :slight_smile:

Thank you guys.

Go to Customize Form (Opportunity), expand the status row and add “Assigned” as one of the options.

Refresh the page. Create a new opportunity and select Assigned. the status will be updated accordingly.

Hope this helps.

1 Like

Thank you so much!

I really wanted this to be automated when a system user gets Assigned (from the left sidebar) to the opportunity though :sweat_smile: will it require lots of custom development?

create a server script for ToDo doctype on save method like below

if doc.reference_type == 'Opportunity':
    quotation = frappe.get_doc(doc.reference_type, doc.reference_name)
    if quotation.status == 'Open' or not quotation.status:
        quotation.status = 'Assigned'
        quotation.save()

the only issue is that after new Assign To created and the opportunity saved, the status field not auto refreshed( the server script is executed on backend, no way to auto refresh the form), you need to manually to refresh to see the changed status.

good luck.

1 Like

OMG, Perfect! Completely worked with only one bug being raised!

When you create a Quotation to the Opportunity, unless you Submit the quotation document, status of the Opportunity becomes null. Once the Quotation is submitted, then the status of the opportunity gets routed just fine.

But thank you so much! This is really good enough and is getting the job done. I do however, wish you’d test the script on your end and fix the small bug :stuck_out_tongue_winking_eye: thank you!

How can we show Quotations as “Submitted” in the status, once the quotation document is submitted? :kissing_closed_eyes:

Thanks guys.

Same scenario with Sales Order and Invoice. I created a work flow and ticked the checkbox “Don’t Override Status” so that the workflow state show as the status and will not be on a draft status only while the document is in the process of approval.

However, the other status like Overdue, Deliver & Bill, Closed and Paid are not shown on shown if the checkbox “Don’t Override Status” unless you uncheck it but the draft status is shown which lead on confusion.

Another scenario I read is, if these other status are not on the workflow, you cannot open the document unless you deactivate the workflow. But I haven’t tested that scenario.

What ways can I solve this?