Dependency to make field read-only after add relationships from the subpanel

I want to make the field read-only after add relationships from the subpanel. From the subpanel, I am pulling one field value from a related module and save in the parent module filed. Then I want to make the parent module filed read-only.

And want to read-only always if the relationship record is available else need to remove read-only.

Parent Module:

Related Module: