We want to use a domain that requires city_id to be on the view
but we can't add it directly there, otherwise _fields_view_get_address
in base_address_city won't do its magic, as it immediately returns
if city_id is already in there.
On the other hand, if city_id is not in the
views, odoo won't let us use it in zip_id's domain.
Fixes a bug introduced here: 5fd93fb8d1
Using the computed allowed + domain with IN is very slow for loading
the partner view, more with the initial set, that gets the whole set
of records.
Luckily, the answer is the magic operator `=?`, that allows to express
a conditional domain that is not applied if the right leaf is False,
complying with the intention of the dynamic domain, and even expanding
it to more conditions for further assistance.
Fixes#1073
* Performance was very poor due to several reasons:
* City name translatable.
* Lack on indexes when deleting obsolete records.
* Some prefetching.
* City was not being searched also by state, having the chance of returning
incorrect matches if same city name on different states.
* Previous code was removing all previous records of zip entries!
* Remove possible obsolete FK keys after migrating from v11.
* Don't need cities for migrating
Previous script required to have cities populated for working, but that's not
usual thing, as people in v11 may choose to not import them, and for older databases
they even weren't that option.
With this improve script, now we populate city table for ZIP entries without city,
so the rest of the queries are properly executed in any case.
* Cover case of res_better_zip w/o country_id
* Avoid error on null zip numbers
Steps:
- Open company form
- Set 'city completion' field
Get 'The state of the partner My Company differs from that in location X'
Disabling _check_zip while writing 'zip' fields from company, as incompatible with the sequence of write operations.
Automatic test is added too.
This module has now been refactored to be more consistent with what base_address_city offers to the location management.
Added dependency to contacts so that I could change the menu location for cities / zip management.
Now, every res.city record has a relation One2many to res.city.zip (old res.better.zip). This way, every zip has a realted city too.
Zips can be searched through city code, zip or city name (same as before).
Modified tests and deleted not needed tests.
Added sql contraints so that zips and cities are unique within it's country / state / city.
* [IMP] base_location: Add lat & long to `better.zip`
* Add latitude and longitude columns to `better.zip`
* [IMP] base_location_geonames_import: Add lat/long
* Add support for latitude & longitude to genomes importer
* Added Icon.
* Improve module description and extracted to README.rst.
* Pass country instead of country_id for advance comparisons.
* Allow to transform city name.
* Some code style.
* Do not remove all entries of a country, but only not found.
* Include hooks for transforming some things.
* Include spanish translation.