New module or new query?

@fab
I tested my decision. You can see my an example next:

  1. custom/modules/Contacts/metadata/subpanels/ForAccounts.php
...
        'primary_address_city'=>array(
            'name'=>'primary_address_city',
            'vname' => 'LBL_LIST_CITY',
            'width' => '20%',
/* add  */
            'target_field' => 'city',
            'target_record_key' => 'id',
            'target_module' => 'Contacts',
            'widget_class' => 'SubPanelDetailViewLink',
/*  */
        ),
...
  1. custom/include/generic/SugarWidgets/SugarWidgetSubPanelDetailViewLink.php
...
class SugarWidgetSubPanelDetailViewLink extends SugarWidgetField
{
    public function displayList(&$layout_def)
    {
        global $focus;
/* add */
$add_params='';
if (!empty($layout_def['target_field'])) {
    $add_params='&detailviewform='.$layout_def['target_field'];
}
/* */
        $module = '';
        $record = '';

...
/* change */
            $link = ajaxLink("index.php?module=$module&action=$action&record={$record}{$parent}$add_params");
//            $link = ajaxLink("index.php?module=$module&action=$action&record={$record}{$parent}");
/*  */
...
  1. custom/modules/Contacts/views/view.detail.php
class ContactsViewDetail extends ViewDetail
{
/* add */
    public function getMetaDataFile()
    {
        if ($_REQUEST['detailviewform'] == 'city') {
            $oldType = $this->type;
            $this->type = $oldType . 'city';
        }
        $metadataFile = parent::getMetaDataFile();
        if ($_REQUEST['detailviewform'] == 'city') {
            $this->type = $oldType;
        }
        
        return $metadataFile;
    }
/* */
  1. Make the file “custom/modules/Contacts/metadata/detailcityviewdefs.php” which base on “modules/Contacts/metadata/detailviewdefs.php”
2 Likes