Approval Code/Pin before amending a PO

Hi,

Does anyone can help me how to implement an approval code (pin code) in a PO?
scenario is if the PO user needs to amend a PO before they can do that the supervisor/manager has to enter an approval code to validate the changes.

Greatly appreciate your help.

Hi @wtgirl,

ERPNext doesn’t support this situation by default, but if you want to make it happen, you can make some changes.

Start by adding two new fields: one called “entered_approval_code” and the other “supervisor_approval_code.”
Make sure the “supervisor_approval_code” field is hidden. Set the PIN as the default value for “entered_approval_code” in the customized form.

When a user Amend a Purchase Order, they need to enter the PIN in the “entered_approval_code” field. After that, compare it with the “supervisor_approval_code.” If they match, you can save the Purchase Order. If not, an error will be shown.

Here server script code.

from frappe import _

def validate(doc, method):
    if doc.docstatus == 0 and doc.amended_from:
        if doc.entered_approval_code != doc.supervisor_approval_code:
            frappe.throw(_("Invalid approval code. Please enter the correct approval code to make changes."))

You can customize the code according to the scenario.

I hope this helps.

Thank You!

2 Likes

Thanks, NCP.

I will try this one.