Email1 on Account is not populated by view.convertlead.php

@mattp

I analyzed the logic for email address. There are several words before results of the analysis.
The object Lead has unconfirmed information about person and company. The information can be set as a rubbish and it can’t be converted to other object. If the information is correctly then the most of the information is describing person. We communicate with people which represent company. When we convert the Lead the first object is Contact. The logic included to object SugarEmailAddress of SuiteCRM.

Now about add email in both objects Contact and Account.

  1. add email1 into array of module Accounts and remove email1 from array of module Contacts in file modules/Leads/metadata/convertdefs.php
  2. change the method display in the file modules/Leads/views/view.convertlead.php
...
                    } elseif ($field == "id") {
                        //If it is not a contact, don't copy the ID from the lead
//                        if ($module == "Contacts") {
                        if ($module == "Contacts" || $module == "Accounts") {
                            $focus->$field = $this->focus->$field;
                        }
...
  1. change the function getEmailAddressWidget in the file include/SugarEmailAddress/getEmailAddressWidget.php
...
    if ($view == 'EditView' || $view == 'QuickCreate' || $view == 'ConvertLead') {
        $module = $focus->module_dir;
//     if ($view == 'ConvertLead' && $module == "Contacts") {
        if ($view == 'ConvertLead' && ($module == "Contacts"|| module == "Accounts") ) {
            $module = "Leads";
        }
...
  1. change the method getEmailAddressWidgetEditView in the file include/SugarEmailAddress/SugarEmailAddress.php
...
        if (!empty($id)) {
            $prefillDataArr = $this->getAddressesByGUID($id, $module);
            //When coming from convert leads, sometimes module is Contacts while the id is for a lead.
//         if (empty($prefillDataArr) && $module == "Contacts") {
            if (empty($prefillDataArr) && ($module == "Contacts" || $module == "Accounts") ) {
                $prefillDataArr = $this->getAddressesByGUID($id, "Leads");
            }
...

After the manipualtions you will get one email address in both objects Contact and Account.

P.S. If you want to get email address in object Account only you should remove module Contacts from the three conditions. This changing doesn’t support with upgrade.