[FIX]crm_partner_assign: now write latitude and longitude to False if the Google geocode API does not return latitude/longitude(for instance, if the api limit is reached). The previous geolocation might be false, and we certainly do not want to forward the lead to the wrong partner

bzr revid: dle@openerp.com-20131104174051-wvmdiwb8oytcb2fb
This commit is contained in:
Denis Ledoux 2013-11-04 18:40:51 +01:00
parent 5f9167c03a
commit b030c9b032
1 changed files with 11 additions and 12 deletions

View File

@ -187,18 +187,17 @@ class crm_lead(osv.osv):
return True return True
# Don't pass context to browse()! We need country name in english below # Don't pass context to browse()! We need country name in english below
for lead in self.browse(cr, uid, ids): for lead in self.browse(cr, uid, ids):
if not lead.country_id: result = None
continue if lead.country_id:
result = geo_find(geo_query_address(street=lead.street, result = geo_find(geo_query_address(street=lead.street,
zip=lead.zip, zip=lead.zip,
city=lead.city, city=lead.city,
state=lead.state_id.name, state=lead.state_id.name,
country=lead.country_id.name)) country=lead.country_id.name))
if result: self.write(cr, uid, [lead.id], {
self.write(cr, uid, [lead.id], { 'partner_latitude': result and result[0] or False,
'partner_latitude': result[0], 'partner_longitude': result and result[1] or False
'partner_longitude': result[1] }, context=context)
}, context=context)
return True return True
def search_geo_partner(self, cr, uid, ids, context=None): def search_geo_partner(self, cr, uid, ids, context=None):