generic_location_address addon: Add addresses to generic locations
Idea
Generic Locations at this time are just names of locations. But in most cases it is not enough, and location address is needed.
As i see, there are two options to add address to location:
- reference to
res.partner
- add set of address-related fields referencing
res.country
,res.country.state
,res.city
, etc
First approach is very simple to implement, but i think partner models is too complex to use it as address.
Second approach is little bit more complex, and requires a set of fields to be added to generic.location
model, idealy with onchanges and proper domains to simplify address input.
So we have to add following fields to generic.location
object according to second approach:
- Country
- Country State
- City
- street
- street2
Onchanges have to implement following logic:
- if Country is changed then State have to be cleared
Following domains have to be added to fields:
- State have to be filtered by selected country. if country is not selected, then state cannot be selected
Note that this addon will not take into account base_address_city
and integration with base_address_city
have to be done in separate addon.
Also generic locations are hierarchial structures, thus we need some logic to use address of parent location if current location have no own address. It may be done on per field basis, for example - parent location is address representing building with Country, State, City, Street fields filled. Sublocations represent rooms / appartments in this building with only street2 field filled. Thus sublocation's address is a combination of Country, State, City, Street fields from parent location and Street2 field from sublocation