Link field with condition

i have 3 tables. manager , stock , transaction

all things is custom

manager = managercode, managername
stock = stockid, sr.no, manager_code
transaction = oldmanager_code ,stockid ,newmanager_code

transaction of stock from one manager to other
now, every stock have manager_code, for define where stock is.

what i need:- in transaction, when i enter oldmanager_code then stockid show only those stock ,which contain by that manager in stock table

Search for get_query and set_query methods.

can you please share some reference ?? LINK

Overriding Link Query By Custom Script

https://frappeframework.com/docs/user/en/guides/app-development/overriding-link-query-by-custom-script