Tried custom logic through doctype permissions hook ?
https://frappe.io/docs/user/en/guides/basics/hooks