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.
<?php
require_once 'vtlib/Vtiger/Module.php';
require_once 'modules/ModComments/ModComments.php';
$commentsModule = Vtiger_Module::getInstance('ModComments');
$fieldInstance = Vtiger_Field::getInstance('related_to', $commentsModule);
$fieldInstance->setRelatedModules(array('Laptop'));// Here is my Custom Module Name
$detailviewblock=ModComments::addWidgetTo('Laptop');
echo "Comments have been added for Your_Custom_Module_Name Module";
?>
```