Browse Source

May 15: [FIX] Bug Fixed 'customer_geolocation'

pull/320/head
RisvanaCybro 12 months ago
parent
commit
434ac8ee84
  1. 12
      customer_geolocation/controllers/main.py
  2. 8
      customer_geolocation/doc/RELEASE_NOTES.md
  3. 2
      customer_geolocation/static/src/css/cust_geolocation.css
  4. 1
      customer_geolocation/views/portal_templates.xml

12
customer_geolocation/controllers/main.py

@ -36,7 +36,6 @@ class PortalGeolocation(CustomerPortal):
def account(self, **post): def account(self, **post):
""" Super CustomerPortal class function and pass the api key value """ Super CustomerPortal class function and pass the api key value
from settings using params to website view file""" from settings using params to website view file"""
res = super(PortalGeolocation, self).account(**post) res = super(PortalGeolocation, self).account(**post)
params = request.env['ir.config_parameter'].sudo() params = request.env['ir.config_parameter'].sudo()
values = params.get_param('base_geolocalize.google_map_api_key') values = params.get_param('base_geolocalize.google_map_api_key')
@ -58,9 +57,8 @@ class PortalGeolocation(CustomerPortal):
the converted Latitude and longitude the converted Latitude and longitude
""" """
res = json.loads(coordinates) res = json.loads(coordinates)
geolocator = Nominatim(user_agent="geoapiExercises") geolocator = Nominatim(user_agent="my-app")
location = geolocator.reverse( location = geolocator.reverse(f'{res.get("lat")},{res.get("lng")}')
str(res.get('lat')) + "," + str(res.get('lng')))
city = "Undefined" city = "Undefined"
suburb = "Undefined" suburb = "Undefined"
state = "Undefined" state = "Undefined"
@ -98,11 +96,9 @@ class PortalGeolocation(CustomerPortal):
Pass the value to website view and set required fields and map Pass the value to website view and set required fields and map
""" """
locator = Nominatim(user_agent="myGeocoder") locator = Nominatim(user_agent='my-app')
location = locator.geocode(address) location = locator.geocode(address)
geolocator = Nominatim(user_agent="geoapiExercises") location_country = locator.reverse(f'{location.latitude},{location.longitude}')
location_country = geolocator.reverse(
str(location.latitude) + "," + str(location.longitude))
addresses = location_country.raw['address'] addresses = location_country.raw['address']
country_code = addresses.get('country_code') country_code = addresses.get('country_code')
country = pytz.country_names[country_code] country = pytz.country_names[country_code]

8
customer_geolocation/doc/RELEASE_NOTES.md

@ -1,7 +1,13 @@
## Module <custmer_geolocation> ## Module <customer_geolocation>
#### 14.03.2023 #### 14.03.2023
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
- Initial commit for Customer Geolocation - Initial commit for Customer Geolocation
#### 09.05.2024
#### Version 16.0.1.0.1
#### BUG FIX
- Bug Fix for Customer Geolocation

2
customer_geolocation/static/src/css/cust_geolocation.css

@ -5,4 +5,4 @@
float: right; float: right;
width: 70%; width: 70%;
height: 450px; height: 450px;
} }

1
customer_geolocation/views/portal_templates.xml

@ -134,7 +134,6 @@
$('#p_code').val(p_code); $('#p_code').val(p_code);
$('#country_show').val(country); $('#country_show').val(country);
$('#geo_state').val("2"); $('#geo_state').val("2");
<!-- }-->
} }
}) })
}); });

Loading…
Cancel
Save