If during deployment you see an error that it is not possible to find relationship object then this code may be useful to list all relations.

It may be caused by such type of SOQL Query:

productList = [ SELECT Id, Name, ProductCode (SELECT Id, .... FROM Installed_Version_Model__r) 
                FROM Product2 
                WHERE ProductCode IN: productCodes];

Execute as anonymous apex:

for(Schema.ChildRelationship cr : Product2.SObjectType.getDescribe().getChildRelationships()){
    System.debug(cr.getChildSObject() + '.' + cr.getField() + ' reversed is: ' + cr.getRelationshipName());
}

Output:

15:40:01:390 USER_DEBUG [2]|DEBUG|Case.SVMXC__Product__c reversed is: SVMXC__Cases__r
15:40:01:395 USER_DEBUG [2]|DEBUG|Order_to_Asset__c.Product__c reversed is: Order_Lines__r
15:40:01:397 USER_DEBUG [2]|DEBUG|Product_Controllership_Details__c.Parent_Product__c reversed is: Installed_Version_Model__r

As you may see having only the name Installed_Version_Model__r it is not easy to find out what is the source field.

   
© Paweł Woźniak