diff --git a/includes/main/WebUI.php b/includes/main/WebUI.php
index 026c7a32749c7a18a8c4a22bfd8dea39449fe510..59ca3434556b94193140924113e4001ddbb66c21 100644
--- a/includes/main/WebUI.php
+++ b/includes/main/WebUI.php
@@ -96,7 +96,7 @@ class Vtiger_WebUI extends Vtiger_EntryPoint {
 		
 		// Better place this here as session get initiated
 		//skipping the csrf checking for the forgot(reset) password 
-		if($request->get('mode') != 'reset' && $request->get('action') != 'Login')
+		if($request->get('mode') != 'reset' && $request->get('action') != 'Login' && $request->get('mode') != 'fromMig')
 			require_once 'libraries/csrf-magic/csrf-magic.php';
 
 		// TODO - Get rid of global variable $current_user
diff --git a/layouts/v7/modules/Migration/MigrationPostProcess.tpl b/layouts/v7/modules/Migration/MigrationPostProcess.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..c46df19f8ac8b0eeda973f9d54916d23c95e8662
--- /dev/null
+++ b/layouts/v7/modules/Migration/MigrationPostProcess.tpl
@@ -0,0 +1,28 @@
+{*+**********************************************************************************
+* The contents of this file are subject to the vtiger CRM Public License Version 1.1
+* ("License"); You may not use this file except in compliance with the License
+* The Original Code is: vtiger CRM Open Source
+* The Initial Developer of the Original Code is vtiger.
+* Portions created by vtiger are Copyright (C) vtiger.
+* All Rights Reserved.
+************************************************************************************}
+
+{strip}
+	<center>
+		<footer class="noprint">
+			<div class="vtFooter">
+				<p>
+					{vtranslate('POWEREDBY')} {$VTIGER_VERSION}&nbsp;
+					&copy; 2004 - {date('Y')}&nbsp;
+					<a href="//www.vtiger.com" target="_blank">vtiger.com</a>
+					&nbsp;|&nbsp;
+					<a href="#" onclick="window.open('copyright.html', 'copyright', 'height=115,width=575').moveTo(210, 620)">{vtranslate('LBL_READ_LICENSE')}</a>
+					&nbsp;|&nbsp;
+					<a href="https://www.vtiger.com/privacy-policy" target="_blank">{vtranslate('LBL_PRIVACY_POLICY')}</a>
+				</p>
+			</div>
+		</footer>
+	</center>
+	{include file='JSResources.tpl'|@vtemplate_path}
+	</div>
+{/strip}
\ No newline at end of file
diff --git a/layouts/v7/skins/images/migration_screen.png b/layouts/v7/skins/images/migration_screen.png
new file mode 100644
index 0000000000000000000000000000000000000000..8b7ef55d92588b080d4fd16f9c641edc012fe0ed
Binary files /dev/null and b/layouts/v7/skins/images/migration_screen.png differ
diff --git a/migrate/index.php b/migrate/index.php
index 42185e8bf3db74bb967548a46cd71ba9fcebf5ca..811ccc3a102cfa6ae8686ae8bf11ac6aaf4b4011 100644
--- a/migrate/index.php
+++ b/migrate/index.php
@@ -16,15 +16,14 @@ include_once 'includes/main/WebUI.php';
 $errorMessage = $_REQUEST['error'];
 if (!$errorMessage) {
 	$extensionStoreInstance = Settings_ExtensionStore_Extension_Model::getInstance();
-	$vtigerStandardModules = array( 'Accounts', 'Assets', 'Calendar', 'Campaigns', 'Contacts', 'CustomerPortal',
-									'Dashboard', 'Documents', 'Emails', 'EmailTemplates', 'Events', 'ExtensionStore',
+	$vtigerStandardModules = array( 'Accounts', 'Assets', 'Calendar', 'Campaigns', 'Contacts', 'CustomerPortal', 'Dashboard', 'Emails', 'EmailTemplates', 'Events', 'ExtensionStore',
 									'Faq', 'Google', 'HelpDesk', 'Home', 'Import', 'Invoice', 'Leads', 'MailManager', 'Mobile', 'ModComments', 'ModTracker',
 									'PBXManager', 'Portal', 'Potentials', 'PriceBooks', 'Products', 'Project', 'ProjectMilestone', 'ProjectTask', 'PurchaseOrder',
 									'Quotes', 'RecycleBin', 'Reports', 'Rss', 'SalesOrder', 'ServiceContracts', 'Services', 'SMSNotifier', 'Users', 'Vendors',
 									'Webforms', 'Webmails', 'WSAPP');
 	$nonPortedExtns = array();
 	$db = PearDatabase::getInstance();
-	$result = $db->pquery('SELECT name FROM vtiger_tab WHERE trim(name) NOT IN ('.generateQuestionMarks($vtigerStandardModules).')', $vtigerStandardModules);
+	$result = $db->pquery('SELECT name FROM vtiger_tab WHERE isentitytype != ? AND presence != ? AND trim(name) NOT IN ('.generateQuestionMarks($vtigerStandardModules).')', array(1, 1, $vtigerStandardModules));
 	while($row = $db->fetch_row($result)) {
 		$module = $row['name'];//label
 		if ($module) {
@@ -42,7 +41,7 @@ if (!$errorMessage) {
 		}
 	}
 	if ($nonPortedExtns) {
-		$portingMessage = 'Following extensions seem to have failed upgrade check with Vtiger7.<br><ul>';
+		$portingMessage = 'Following custom modules are not compatible with Vtiger 7. Please disable these modules to proceed.';
 		foreach ($nonPortedExtns as $module) {
 			$portingMessage .= "<li>$module</li>";
 		}
@@ -90,20 +89,27 @@ if (!$errorMessage) {
 					<hr>
 					<div class="row">
 						<div class="col-lg-4 welcome-image">
-							<img src="resources/images/migration_screen.png" alt="Vtiger Logo" style="width: 100%;"/>
+							<img src="resources/images/migration_screen.png" alt="Vtiger Logo" style="width: 100%; margin-left: 15px;"/>
 						</div>
 						<?php
 							$currentVersion = explode('.', $vtiger_current_version);
 							 if ($portingMessage) { ?>
-								<div class="col-lg-8">
+								<div class="col-lg-1"></div>
+								<div class="col-lg-7">
 									<h3><font color="red">WARNING : Cannot continue with Migration</font></h3><br>
 									<p><?php echo $portingMessage;?></p>
 								</div>
 							</div>
 							<div class="button-container col-lg-12">
-								<input type="button" onclick="window.location.href='index.php'" class="btn btn-large btn-primary pull-right" value="Finish"/>
+								<div class="pull-right">
+									<form action="../index.php?module=Migration&action=DisableModules&mode=fromMig" method="POST">
+										<input type="hidden" name="modulesList" <?php echo 'value="'.Vtiger_Util_Helper::toSafeHTML(Zend_JSON::encode($nonPortedExtns)).'"'; ?> />
+										<input type="submit" class="btn btn-warning" value="Disable modules & Proceed"/>
+										<input type="button" onclick="window.location.href='../index.php'" class="btn btn-default" value="Close"/>
+									</form>
+								</div>
 						<?php } else if($currentVersion[0] >= 6 && $currentVersion[1] >= 0) { ?>
-							<div class="col-lg-8">
+							<div class="col-lg-8" style="padding-left: 30px;">
 								<h3> Welcome to Vtiger Migration</h3>
 								<?php if(isset($errorMessage)) {
 									echo '<span><font color="red"><b>'.filter_var($errorMessage, FILTER_SANITIZE_STRING).'</b></font></span><br><br>';
@@ -111,10 +117,10 @@ if (!$errorMessage) {
 								<p>We have detected that you have <strong>Vtiger <?php echo $vtiger_current_version ?></strong> installation.<br><br></p>
 								<p>
 									<strong>Warning: </strong>
-									Please note that it is not possible to revert back to <?php echo $vtiger_current_version ?>&nbsp; after the upgrade to vtiger 6 <br>
+									Please note that it is not possible to revert back to <?php echo $vtiger_current_version ?>&nbsp;after the upgrade to vtiger 7 <br>
 									So, it is important to take a backup of the <?php echo $vtiger_current_version ?> installation, including the source files and database.
 								</p><br>
-								<form action="../index.php?module=Migration&action=Extract&mode=reset" method="POST">
+								<form action="../index.php?module=Migration&action=Extract&mode=fromMig" method="POST">
 									<div><input type="checkbox" id="checkBox1" name="checkBox1"/><div class="chkbox"></div> I have taken the backup of database <a href="http://community.vtiger.com/help/vtigercrm/administrators/backup.html" target="_blank" >(how to?)</a></div><br>
 									<div><input type="checkbox" id="checkBox2" name="checkBox2"/><div class="chkbox"></div> I have taken the backup of source folder <a href="http://community.vtiger.com/help/vtigercrm/administrators/backup.html" target="_blank" >(how to?)</a></div><br>
 									<br>
@@ -127,12 +133,13 @@ if (!$errorMessage) {
 									</div>
 									<br><br><br>
 									<div class="button-container">
-										<input type="submit" class="btn btn-large btn-primary" id="startMigration" name="startMigration" value="Start Migration" />
+										<input type="submit" class="btn btn-primary" id="startMigration" name="startMigration" value="Start Migration" />
 									</div>
 								</form>
 							</div>
 						<?php } else if($currentVersion[0] < 6) { ?>
-							<div class="col-lg-8">
+							<div class="col-lg-1"></div>
+							<div class="col-lg-7">
 								<h3><font color="red">WARNING : Cannot continue with Migration</font></h3><br>
 								<p>We detected that this installation is running <strong>Vtiger CRM</strong>
 										<?php
@@ -144,17 +151,18 @@ if (!$errorMessage) {
 								</p>
 							</div>
 							<div class="button-container col-lg-12">
-								<input type="button" onclick="window.location.href='index.php'" class="btn btn-large btn-primary pull-right" value="Finish"/>
+								<input type="button" onclick="window.location.href='index.php'" class="btn btn-primary pull-right" value="Finish"/>
 						<?php } else { ?>
-								<div class="col-lg-8">	
-									<h3><font color="red">WARNING : Cannot continue with Migration</font></h3>
-									<br>
-									<p>
-										We detected that this source is upgraded latest version.
-									</p>
-								</div>
-								<div class="button-container col-lg-12">
-									<input type="button" onclick="window.location.href='index.php'" class="btn btn-large btn-primary pull-right" value="Finish"/>
+							<div class="col-lg-1"></div>
+							<div class="col-lg-7">
+								<h3><font color="red">WARNING : Cannot continue with Migration</font></h3>
+								<br>
+								<p>
+									We detected that this source is upgraded latest version.
+								</p>
+							</div>
+							<div class="button-container col-lg-12">
+								<input type="button" onclick="window.location.href='index.php'" class="btn btn-primary pull-right" value="Finish"/>
 						<?php } ?>
 					</div>
 				</div>
diff --git a/migrate/resources/images/migration_screen.png b/migrate/resources/images/migration_screen.png
index 3db19b143950c728beb577b82be9163626e909ad..83334830e84a717532dca988ce23a997a0db1e44 100644
Binary files a/migrate/resources/images/migration_screen.png and b/migrate/resources/images/migration_screen.png differ
diff --git a/modules/Migration/actions/DisableModules.php b/modules/Migration/actions/DisableModules.php
new file mode 100644
index 0000000000000000000000000000000000000000..f04fb9195492b4c8390a2373283e88e135d60118
--- /dev/null
+++ b/modules/Migration/actions/DisableModules.php
@@ -0,0 +1,23 @@
+<?php
+/*+**********************************************************************************
+ * The contents of this file are subject to the vtiger CRM Public License Version 1.1
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is: vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ ************************************************************************************/
+
+class Migration_DisableModules_Action extends Vtiger_Action_Controller {
+
+	public function process(Vtiger_Request $request) {
+		$modulesList = $request->get('modulesList');
+		if ($modulesList) {
+			$moduleManagerModel = new Settings_ModuleManager_Module_Model();
+			$moduleManagerModel->disableModule($modulesList);
+		}
+
+		header('Location: migrate/index.php');
+	}
+
+}
diff --git a/modules/Migration/schema/660_to_700.php b/modules/Migration/schema/660_to_700.php
index b3bc9a13af4d296f0605faf2a0e89410680cdbd9..05fb66345e18c675022f1e7d03beddd9a5b1e7be 100644
--- a/modules/Migration/schema/660_to_700.php
+++ b/modules/Migration/schema/660_to_700.php
@@ -2170,8 +2170,7 @@ if(defined('VTIGER_UPGRADE')) {
 
 	$skippedTables = array('Calendar' => array('vtiger_seactivityrel', 'vtiger_cntactivityrel', 'vtiger_salesmanactivityrel'));
 	$allEntityModules = Vtiger_Module_Model::getEntityModules();
-	require_once './config.inc.php';
-	$dbName = $dbconfig['db_name'];
+	$dbName = $db->dbName;
 	foreach ($allEntityModules as $tabId => $moduleModel) {
 		$moduleName = $moduleModel->getName();
 		$baseTableName = $moduleModel->basetable;
@@ -2200,10 +2199,18 @@ if(defined('VTIGER_UPGRADE')) {
 
 				//Checking foriegn key with base table
 				foreach ($relatedTables as $tableName => $index) {
-					$checkIfRelConstraintExists = $db->pquery($query, array($dbName, '%fk%', $tableName, $index, $baseTableName, $baseTableIndex));
+					$referenceTable = $baseTableName;
+					$referenceColumn = $baseTableIndex;
+
+					if ($tableName == 'vtiger_producttaxrel' || $tableName == 'vtiger_inventoryproductrel') {
+						$referenceTable = 'vtiger_crmentity';
+						$referenceColumn = 'crmid';
+					}
+
+					$checkIfRelConstraintExists = $db->pquery($query, array($dbName, '%fk%', $tableName, $index, $referenceTable, $referenceColumn));
 					if ($db->num_rows($checkIfRelConstraintExists) < 1) {
-						$newForiegnKey = "fk_$baseTableIndex"."_$tableName";
-						$db->pquery("ALTER TABLE $tableName ADD CONSTRAINT $newForiegnKey FOREIGN KEY ($index) REFERENCES $baseTableName ($baseTableIndex) ON DELETE CASCADE", array());
+						$newForiegnKey = "fk_$referenceColumn"."_$tableName";
+						$db->pquery("ALTER TABLE $tableName ADD CONSTRAINT $newForiegnKey FOREIGN KEY ($index) REFERENCES $referenceTable ($referenceColumn) ON DELETE CASCADE", array());
 					}
 				}
 			}
diff --git a/modules/Migration/views/Index.php b/modules/Migration/views/Index.php
index 95943fae3c7eb8cf22e7de9f8a0c27e4cb01b4a8..eb0fcde720eecb98321b65864d8652b1a3d6f309 100644
--- a/modules/Migration/views/Index.php
+++ b/modules/Migration/views/Index.php
@@ -55,7 +55,7 @@ class Migration_Index_View extends Vtiger_Basic_View {
 	public function postProcess(Vtiger_Request $request) {
 		$viewer = $this->getViewer($request);
 		$moduleName = $request->getModule();
-		$viewer->view('InstallPostProcess.tpl', 'Install');
+		$viewer->view('MigrationPostProcess.tpl', $moduleName);
 	}
 
 	public function getHeaderCss(Vtiger_Request $request) {
diff --git a/vtigerversion.php b/vtigerversion.php
index cbe25e18b96e9bcb17644bd445e6dc9e68d790f1..6a6f3bc7035d9533b03e9279cdc70348f90507ec 100644
--- a/vtigerversion.php
+++ b/vtigerversion.php
@@ -8,7 +8,7 @@
  * All Rights Reserved.
  ************************************************************************************/
 
-$patch_version = '20160714'; // -ve timestamp before release, +ve timestamp after release.
+$patch_version = '-20170517'; // -ve timestamp before release, +ve timestamp after release.
 $modified_database = '';
 $vtiger_current_version = '7.0.0';
 $_SESSION['vtiger_version'] = $vtiger_current_version;