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