Set country and subdivision based on zip

Although I’m not fond of Sergi’s proposal, I don’t think your arguments here match those expressed in Default currency for a party - #11 by 2cadz

Default values always have the risk of being wrong (otherwise those fields wouldn’t even be necessary), and may be specially annoying when the system tries to guess them.

I like this proposal more than the original one That’s more or less what you get when you use the party_zip module but there you use a M2O field (which works great when you find what you’re looking for but sucks if you don’t). We use the module only in case the company wants to enforce the use of the zips database.

It is not the same guessing from static data and guessing from past behavior of the user. The second one evolves and learns.

From this discussion, I think it is clear that:

  • the address fields must be inverted
  • we can use the zip code value to fill other field if the country is known and if the value is unique. We can use the country zip or allow to call an external service.
  • we may create a module that adds a field with auto-completion from a service (like Google Maps) on creation (invisible if id >= 0).
  • we may create a module that validate the address through an external service (like Google Maps or UPS).
1 Like

I’m not sure what will be the best layout for the view. If we have the autocomplete feature in my we may use:

Country        Zip
City           Subdivision 

But this does not feel very natural to me.
On the other hand if we invert the rows:

Country       Subdivision
Zip           City

This will make the user enter the subdivision without the zip so we will never autocomplete the subdivision.

If one could set a default country, within that country, the zip code would need to be unique. But I don’t know how to set a default country, eg. when adding parties, so I have to do this manually.