[FIX] map field

bzr revid: tfr@openerp.com-20110421130316-6qo9j6a9rco20iwr
This commit is contained in:
tfr@openerp.com
2011-04-21 15:03:16 +02:00
parent 0e950f71a9
commit 685d89fe66
3 changed files with 13 additions and 17 deletions
+2 -6
View File
@@ -912,7 +912,7 @@ def import_opportunities(sugar_obj, cr, uid, context=None):
return True
MAP_FIELDS = {'Opportunities': #Object Mapping name
{'dependencies' : ['Users', 'Accounts', 'Contacts'], #Object to import before this table
{'dependencies' : ['Users', 'Accounts', 'Contacts', 'Leads'], #Object to import before this table
'process' : import_opportunities,
},
'Leads':
@@ -979,8 +979,7 @@ class import_sugarcrm(osv.osv):
_name = "import.sugarcrm"
_description = __doc__
_columns = {
'lead': fields.boolean('Leads', help="If Leads are checked, SugarCRM Leads data imported in OpenERP crm-Lead form"),
'opportunity': fields.boolean('Opportunities', help="If Opportunities are checked, SugarCRM opportunities data imported in OpenERP crm-Opportunity form"),
'opportunity': fields.boolean('Lead and Opportunities', help="If Opportunities are checked, SugarCRM opportunities data imported in OpenERP crm-Opportunity form"),
'user': fields.boolean('User', help="If Users are checked, SugarCRM Users data imported in OpenERP Users form"),
'contact': fields.boolean('Contacts', help="If Contacts are checked, SugarCRM Contacts data imported in OpenERP partner address form"),
'account': fields.boolean('Accounts', help="If Accounts are checked, SugarCRM Accounts data imported in OpenERP partners form"),
@@ -996,7 +995,6 @@ class import_sugarcrm(osv.osv):
'password': fields.char('Password', size=24),
}
_defaults = { #to be set to true, but easier for debugging
'lead': False,
'opportunity': False,
'user' : False,
'contact' : False,
@@ -1016,8 +1014,6 @@ class import_sugarcrm(osv.osv):
context = {}
key_list = []
for current in self.browse(cr, uid, ids, context):
if current.lead:
key_list.append('Leads')
if current.opportunity:
key_list.append('Opportunities')
if current.user:
@@ -12,7 +12,6 @@
<group colspan="4" width="500">
<separator string="Select SugarCRM Module Name" colspan="4"/>
<group colspan="4" col="6">
<field name="lead" />
<field name="opportunity" />
<field name= "meeting" />
<field name= "call" />
@@ -25,15 +25,16 @@ def sugarcrm_fields_mapp(dict_sugar, openerp_dict):
for key,val in openerp_dict.items():
if key not in fields and dict_sugar:
fields.append(key)
if not isinstance(val, list):
val = [val]
#Allow to print a bit more pretty way long list of data in the same field
if len(val) >= 1 and val[0] == "__prettyprint__":
val = val[1:]
data_lst.append('\n\n'.join(map(lambda x : x + ": " + str(dict_sugar[x]), val)))
else:
if key == 'duration':
data_lst.append('.'.join(map(lambda x : str(dict_sugar[x]), val)))
if isinstance(val, list) and val:
#Allow to print a bit more pretty way long list of data in the same field
if len(val) >= 1 and val[0] == "__prettyprint__":
val = val[1:]
data_lst.append('\n\n'.join(map(lambda x : x + ": " + dict_sugar.get(val,''), val)))
else:
data_lst.append(' '.join(map(lambda x : str(dict_sugar[x]), val)))
if key == 'duration':
data_lst.append('.'.join(map(lambda x : dict_sugar.get(val,''), val)))
else:
data_lst.append(' '.join(map(lambda x : dict_sugar.get(val,''), val)))
else:
data_lst.append(dict_sugar.get(val,''))
return fields,data_lst