That for, you have to apply the client script for quotation and sales invoice doctype.
Here i provide the client script for the quotation.
frappe.ui.form.on("Quotation", {
refresh: function(frm) {
frm.set_query("contact_person", function(){
return {
"filters": [
["Dynamic Link", "link_doctype", "=", "Customer"]
]
};
});
}
});
Please also set the script for the sales invoice.
Then reload Ctrl+Shift+R and check it.
Reference: