IMP sale_planner better error handling and fixing '-' in res.partner.geo_localize()

This commit is contained in:
Jared Kipe
2018-09-24 11:21:54 -07:00
committed by Jared Kipe
parent 1c0eb33539
commit fb70888119
2 changed files with 3 additions and 3 deletions

View File

@@ -15,8 +15,8 @@ class Partner(models.Model):
for partner in self.with_context(lang='en_US'):
if ZipcodeSearchEngine and partner.zip:
with ZipcodeSearchEngine() as search:
zipcode = search.by_zipcode(partner.zip)
if zipcode:
zipcode = search.by_zipcode(str(self.zip).split('-')[0])
if zipcode and zipcode['Latitude']:
partner.write({
'partner_latitude': zipcode['Latitude'],
'partner_longitude': zipcode['Longitude'],

View File

@@ -55,7 +55,7 @@ class FakePartner():
@property
def date_localization(self):
if not hasattr(self, 'date_localization'):
if not hasattr(self, 'date_localization') and self.date_localization:
self.date_localization = 'TODAY!'
# The fast way.
if ZipcodeSearchEngine and self.zip: