mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
FIX sale_planner It is possible that the 'fall back' core geo_localize can raise an index error
This commit is contained in:
@@ -13,6 +13,7 @@ class Partner(models.Model):
|
|||||||
def geo_localize(self):
|
def geo_localize(self):
|
||||||
# We need country names in English below
|
# We need country names in English below
|
||||||
for partner in self.with_context(lang='en_US'):
|
for partner in self.with_context(lang='en_US'):
|
||||||
|
try:
|
||||||
if SearchEngine and partner.zip:
|
if SearchEngine and partner.zip:
|
||||||
with SearchEngine() as search:
|
with SearchEngine() as search:
|
||||||
zipcode = search.by_zipcode(str(self.zip).split('-')[0])
|
zipcode = search.by_zipcode(str(self.zip).split('-')[0])
|
||||||
@@ -26,4 +27,6 @@ class Partner(models.Model):
|
|||||||
super(Partner, partner).geo_localize()
|
super(Partner, partner).geo_localize()
|
||||||
else:
|
else:
|
||||||
super(Partner, partner).geo_localize()
|
super(Partner, partner).geo_localize()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -58,8 +58,9 @@ class FakePartner():
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def date_localization(self):
|
def date_localization(self):
|
||||||
if not hasattr(self, 'date_localization') and self.date_localization:
|
if not self._date_localization:
|
||||||
self.date_localization = 'TODAY!'
|
try:
|
||||||
|
self._date_localization = 'TODAY!'
|
||||||
# The fast way.
|
# The fast way.
|
||||||
if SearchEngine and self.zip:
|
if SearchEngine and self.zip:
|
||||||
with SearchEngine() as search:
|
with SearchEngine() as search:
|
||||||
@@ -67,7 +68,7 @@ class FakePartner():
|
|||||||
if zipcode and zipcode.lat:
|
if zipcode and zipcode.lat:
|
||||||
self.partner_latitude = zipcode.lat
|
self.partner_latitude = zipcode.lat
|
||||||
self.partner_longitude = zipcode.lng
|
self.partner_longitude = zipcode.lng
|
||||||
return self.date_localization
|
return self._date_localization
|
||||||
|
|
||||||
# The slow way.
|
# The slow way.
|
||||||
result = geo_find(geo_query_address(
|
result = geo_find(geo_query_address(
|
||||||
@@ -78,8 +79,9 @@ class FakePartner():
|
|||||||
if result:
|
if result:
|
||||||
self.partner_latitude = result[0]
|
self.partner_latitude = result[0]
|
||||||
self.partner_longitude = result[1]
|
self.partner_longitude = result[1]
|
||||||
|
except:
|
||||||
return self.date_localization
|
self._date_localization = 'ERROR'
|
||||||
|
return self._date_localization
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user