def assign_geo_localize(self, latitude=False, longitude=False): if latitude and longitude: self.write({ 'partner_latitude': latitude, 'partner_longitude': longitude }) return True # Don't pass context to browse()! We need country name in english below for lead in self: if lead.partner_latitude and lead.partner_longitude: continue 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)) if result is None: result = geo_find(geo_query_address( city=lead.city, state=lead.state_id.name, country=lead.country_id.name )) if result: lead.write({ 'partner_latitude': result[0], 'partner_longitude': result[1] }) return True
def assign_geo_localize(self, latitude=False, longitude=False): if latitude and longitude: self.write({ 'partner_latitude': latitude, 'partner_longitude': longitude }) return True # Don't pass context to browse()! We need country name in english below for lead in self: if lead.partner_latitude and lead.partner_longitude: continue 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)) if result is None: result = geo_find( geo_query_address(city=lead.city, state=lead.state_id.name, country=lead.country_id.name)) if result: lead.write({ 'partner_latitude': result[0], 'partner_longitude': result[1] }) return True
def geo_localize(self): google_api_key = self.env['ir.config_parameter'].sudo().get_param( 'google.api_key_geocode', default='') for lead in self.with_context(lang='en_US'): result = geo_find(addr=geo_query_address( street=lead.street, zip=lead.zip, city=lead.city, state=lead.state_id.name, country=lead.country_id.name), apikey=google_api_key) if result is None: result = geo_find(addr=geo_query_address( city=lead.city, state=lead.state_id.name, country=lead.country_id.name), apikey=google_api_key) if result: lead.write({ 'customer_latitude': result[0], 'customer_longitude': result[1] }) return True
def _geo_localize(cls, apikey, street='', zip_code='', city='', state='', country=''): search = geo_query_address( street=street, zip=zip_code, city=city, state=state, country=country) result = geo_find(search, apikey) if result is None: search = geo_query_address(city=city, state=state, country=country) result = geo_find(search, apikey) return result
def map_location_setter(self): result = geo_find( geo_query_address(street=self.street, zip=self.zip, city=self.city, state=self.state_id.name, country=self.country_id.name)) if result: if not self.google_map_partner: maps_loc = { u'position': { u'lat': 20.593684, u'lng': 78.96288 }, u'zoom': 3 } json_map = json.dumps(maps_loc) self.google_map_partner = json_map if self.google_map_partner: map_loc = self.google_map_partner maps_loc = json.loads(map_loc) maps_loc['position']['lat'] = result[0] maps_loc['position']['lng'] = result[1] maps_loc['zoom'] = 3 json_map = json.dumps(maps_loc) self.google_map_partner = json_map
def geo_localize(self): for lead in self.with_context(lang='en_US'): 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 is None: result = geo_find( geo_query_address(city=lead.city, state=lead.state_id.name, country=lead.country_id.name)) if result: lead.write({ 'customer_latitude': result[0], 'customer_longitude': result[1] }) return True