doc.save(ignore_permissions=True) not working (v13)

I am creating a public API for inserting new record. I actually did it on from version 12 but its not working now on version 13. I got Not Permitted when inserting new record.

Here’s the code.

@frappe.whitelist(allow_guest=True)
def add_customer():
    data = json.loads(frappe.request.data)
    full_name = data['customer_fname'] + " " + data['customer_lname']
    cust_name = full_name.title()

    customer = frappe.new_doc('Customer')
    customer.customer_name = cust_name
    customer.mobile_no = data['mobile_no']
    customer.email_id = data['email_id']
    customer.address_line1 = data['address_line1']
    customer.city = data['city']
    customer.country = data['country']
    customer.pincode = data['postal_code']

    customer.save(ignore_permissions=True)
    frappe.db.commit()

Thanks.

1 Like

I am having similar issue on version 13 the ignore_permissions=True flag doesn’t seem to work. Does anyone have a fix for this?

add below code in end check error log in erpnext for any issue

except Exception as e:
frappe.log_error(frappe.get_traceback())
gen_response(500, cstr(e))

Thanks @mohitchechani , i found my problem, i had a chain of save document that i need to as ignore_permissions=True to as well as the frappe.db.get_list() also

The Contact and Address is auto-generated on creation of Customer. The Contact and Address requires permission that’s why it throws Not Permitted.

1 Like