I hope all of you are doing well. I have created 1:M relationship between custom modules and Custom relationship used this script.we have run this script in root folder. 1:M relationship are working fine and relationship view also perfect.
Calendar (Activities)
<?php
include_once('vtlib/Vtiger/Module.php');
$moduleInstance = Vtiger_Module::getInstance('Laptops'); //Custom Module Name
$accountsModule = Vtiger_Module::getInstance('Calendar');
$relationLabel = 'Activities';
$moduleInstance->setRelatedList(
$accountsModule, $relationLabel, Array('ADD','SELECT'), 'get_activities'
);
echo "Activities have been added for Your_Custom_Module_Name Module";
?>