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):
|
||||
# We need country names in English below
|
||||
for partner in self.with_context(lang='en_US'):
|
||||
try:
|
||||
if SearchEngine and partner.zip:
|
||||
with SearchEngine() as search:
|
||||
zipcode = search.by_zipcode(str(self.zip).split('-')[0])
|
||||
@@ -26,4 +27,6 @@ class Partner(models.Model):
|
||||
super(Partner, partner).geo_localize()
|
||||
else:
|
||||
super(Partner, partner).geo_localize()
|
||||
except:
|
||||
pass
|
||||
return True
|
||||
|
||||
@@ -59,6 +59,7 @@ class FakePartner():
|
||||
@property
|
||||
def date_localization(self):
|
||||
if not self._date_localization:
|
||||
try:
|
||||
self._date_localization = 'TODAY!'
|
||||
# The fast way.
|
||||
if SearchEngine and self.zip:
|
||||
@@ -78,7 +79,8 @@ class FakePartner():
|
||||
if result:
|
||||
self.partner_latitude = result[0]
|
||||
self.partner_longitude = result[1]
|
||||
|
||||
except:
|
||||
self._date_localization = 'ERROR'
|
||||
return self._date_localization
|
||||
|
||||
def __getattr__(self, item):
|
||||
|
||||
Reference in New Issue
Block a user