def import_project_account(self, val):
     partner_id = False
     partner_invoice_id = False        
     sugar_project_account = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Project', module_id=val.get('id'), related_module=self.TABLE_ACCOUNT, query=None, deleted=None)
     sugar_project_contact = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Project', module_id=val.get('id'), related_module=self.TABLE_CONTACT, query=None, deleted=None)
     for contact_id in sugar_project_contact:
         partner_invoice_id = self.get_mapped_id(self.TABLE_CONTACT, contact_id)
     for account_id in sugar_project_account:
         partner_id = self.get_mapped_id(self.TABLE_ACCOUNT, account_id)
     return partner_id, partner_invoice_id      
 def import_related_document(self, val):
     res_model = False
     res_id = False
     sugar_document_account = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module='Accounts', query=None, deleted=None)
     sugar_document_contact = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_CONTACT, query=None, deleted=None)
     sugar_document_opportunity = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_OPPORTUNITY, query=None, deleted=None)
     sugar_document_case = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_CASE, query=None, deleted=None)
     sugar_document_bug = sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Documents', module_id=val.get('id'), related_module=self.TABLE_BUG, query=None, deleted=None)
     if sugar_document_account:
         res_id = self.get_mapped_id(self.TABLE_ACCOUNT,sugar_document_account[0])
         res_model = 'res.partner'
     elif sugar_document_contact:
         res_id = self.get_mapped_id(self.TABLE_CONTACT, sugar_document_contact[0])
         res_model = 'res.partner.address'
     elif sugar_document_opportunity:
         res_id = self.get_mapped_id(self.TABLE_OPPORTUNITY, sugar_document_opportunity[0])
         res_model = 'crm.lead'
     elif sugar_document_case:
         res_id = self.get_mapped_id(self.TABLE_CASE, sugar_document_case[0])
         res_model = 'crm.claim'
     elif sugar_document_bug:
         res_id = self.get_mapped_id(self.TABLE_BUG, sugar_document_bug[0])
         res_model = 'project.issue'
     return res_id,res_model
 def import_opportunity_contact(self, val):
     sugar_opportunities_contact = set(sugar.relation_search(self.context.get('port'), self.context.get('session_id'), 'Opportunities', module_id=val.get('id'), related_module='Contacts', query=None, deleted=None))
         
     partner_contact_id = False 
     partner_contact_email = False       
     partner_address_obj = self.obj.pool.get('res.partner.address')
     partner_xml_id = self.name_exist(self.TABLE_ACCOUNT, val['account_name'], 'res.partner')
     
     for contact in sugar_opportunities_contact:
         address_id = self.get_mapped_id(self.TABLE_CONTACT, contact)
         if address_id:                    
             address = partner_address_obj.browse(self.cr, self.uid, address_id)
             partner_name = address.partner_id and address.partner_id.name or False
             if not partner_name: #link with partner id 
                 fields = ['partner_id/id']
                 data = [partner_xml_id]
                 self.import_object(fields, data, 'res.partner.address', self.TABLE_CONTACT, contact, self.DO_NOT_FIND_DOMAIN)
             if not partner_name or partner_name == val.get('account_name'):
                 partner_contact_id = self.xml_id_exist(self.TABLE_CONTACT, contact)
                 partner_contact_email = address.email
     return partner_contact_id, partner_contact_email