[IMP] Country from zip checkin roommatik

This commit is contained in:
Dario Lodeiros
2019-09-08 18:02:58 +02:00
parent 99325ed3fb
commit bc19a83d5a
2 changed files with 9 additions and 2 deletions

View File

@@ -19,7 +19,8 @@
'partner_contact_gender',
'partner_second_lastname',
'partner_contact_birthdate',
'base_iso3166'
'base_iso3166',
'base_location',
],
'data': [
'data/res_users_data.xml'

View File

@@ -68,14 +68,20 @@ class ResPartner(models.Model):
return [False, error_name]
def rm_prepare_customer(self, customer):
zip = self.env['res.better.zip'].search([
('name', 'ilike', customer['Address']['ZipCode'])])
# Check Sex string
if customer['Sex'] not in {'male', 'female'}:
customer['Sex'] = ''
# Check state_id
state = self.env['res.country.state'].search([
('name', 'ilike', customer['Address']['Province'])])
if not state and zip:
state = zip.state_id
country = self.env['res.country'].search([
('code_alpha3', '=', customer['Address']['Country'])])
if not country and zip:
country = zip.country_id
# Create Street2s
street_2 = customer['Address']['House']
street_2 += ' ' + customer['Address']['Flat']
@@ -87,7 +93,7 @@ class ResPartner(models.Model):
'birthdate_date': datetime.strptime(
customer['Birthday'], DEFAULT_ROOMMATIK_DATE_FORMAT).date(),
'gender': customer['Sex'],
'zip': customer['Address']['ZipCode'],
'zip': zip,
'city': customer['Address']['City'],
'street': customer['Address']['Street'],
'street2': street_2,