Not allowed to disable Mandatory for standard fields

Not able to remove mandatory fields

Try enable developer mode

I would try “Mandatory depends on” .

This is a requirement I’ve had in the past. I’ve only found 1 solution.

  1. Create a custom app.
  2. Add a hook after_migrate
def after_migrate():
    frappe.conf.developer_mode = 1
    for doctype in ("Quotation", "Purchase Order",):
        doc = frappe.get_doc("DocType", doctype)
        for field in doc.fields:
             if field.fieldname == "items":
                 field.reqd = 0
        doc.save()
    frappe.conf.developer_mode 0
  1. Install the custom app

Now every time you update ERPNext this hook will execute and make the items table not mandatory for each specified doctype.

Please be aware: There is some validation logic in the python controllers that also validate items exists in the table. You must also override this validation with override_doctype_class hook.

1 Like

Hi @Abhishek,

Adding to @Prabhas_Chakraborty, @TurkerTunali and @dj12djdjs answer,

You can also use the Property Setter for removing mandatory fields.
Please check it.

Thank You!

6 Likes

@NCP thanks…

It works, thanks