diff --git a/CHANGELOG b/CHANGELOG
index cb967767f1..4caf72a74f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Rename zip into postal code
* Add simple distance between parties
* Configure available identifiers
* Add ar, at, by, cn, cr, gr, id, il, kr, lt, no, ro and se identifiers
diff --git a/address.py b/address.py
index 06228ac28c..fc998c8571 100644
--- a/address.py
+++ b/address.py
@@ -34,7 +34,7 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
help="If filled, replace the name of the party for address formatting")
name = fields.Char("Building Name")
street = fields.Text("Street")
- zip = fields.Char("Zip")
+ postal_code = fields.Char("Postal Code")
city = fields.Char("City")
country = fields.Many2One('country.country', "Country")
subdivision_types = fields.Function(
@@ -59,7 +59,7 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
super(Address, cls).__setup__()
cls._order.insert(0, ('party', 'ASC'))
cls.__rpc__.update(
- autocomplete_zip=RPC(instantiate=0, cache=dict(days=1)),
+ autocomplete_postal_code=RPC(instantiate=0, cache=dict(days=1)),
autocomplete_city=RPC(instantiate=0, cache=dict(days=1)),
)
@@ -67,6 +67,10 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
+ table = cls.__table_handler__(module_name)
+
+ # Migration from 5.8: rename zip to postal code
+ table.column_rename('zip', 'postal_code')
super(Address, cls).__register__(module_name)
@@ -99,25 +103,25 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
def _autocomplete_search(self, domain, name):
pool = Pool()
- Zip = pool.get('country.zip')
+ PostalCode = pool.get('country.postal_code')
if domain:
- records = Zip.search(domain, limit=self._autocomplete_limit)
+ records = PostalCode.search(domain, limit=self._autocomplete_limit)
if len(records) < self._autocomplete_limit:
return sorted({getattr(z, name) for z in records})
return []
@fields.depends('city', methods=['_autocomplete_domain'])
- def autocomplete_zip(self):
+ def autocomplete_postal_code(self):
domain = self._autocomplete_domain()
if self.city:
domain.append(('city', 'ilike', '%%%s%%' % self.city))
- return self._autocomplete_search(domain, 'zip')
+ return self._autocomplete_search(domain, 'postal_code')
- @fields.depends('zip', methods=['_autocomplete_domain'])
+ @fields.depends('postal_code', methods=['_autocomplete_domain'])
def autocomplete_city(self):
domain = self._autocomplete_domain()
- if self.zip:
- domain.append(('zip', 'ilike', '%s%%' % self.zip))
+ if self.postal_code:
+ domain.append(('postal_code', 'ilike', '%s%%' % self.postal_code))
return self._autocomplete_search(domain, 'city')
def get_full_address(self, name):
@@ -140,7 +144,7 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
'attn': '',
'name': getattr(self, 'name', None) or '',
'street': getattr(self, 'street', None) or '',
- 'zip': getattr(self, 'zip', None) or '',
+ 'postal_code': getattr(self, 'postal_code', None) or '',
'city': getattr(self, 'city', None) or '',
'subdivision': (self.subdivision.name
if getattr(self, 'subdivision', None) else ''),
@@ -150,6 +154,8 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
'country_code': (self.country.code or ''
if getattr(self, 'country', None) else ''),
}
+ # Keep zip for backward compatibility
+ substitutions['zip'] = substitutions['postal_code']
if context.get('address_from_country') == getattr(self, 'country', ''):
substitutions['country'] = ''
if context.get('address_with_party', False):
@@ -185,7 +191,7 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
party,
self.name,
street,
- self.zip,
+ self.postal_code,
self.city,
country]))
@@ -199,7 +205,7 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
('party',) + tuple(clause[1:]),
('name',) + tuple(clause[1:]),
('street',) + tuple(clause[1:]),
- ('zip',) + tuple(clause[1:]),
+ ('postal_code',) + tuple(clause[1:]),
('city',) + tuple(clause[1:]),
('country',) + tuple(clause[1:]),
]
@@ -246,7 +252,7 @@ class AddressFormat(DeactivableMixin, MatchMixin, ModelSQL, ModelView):
"- ${name}\n"
"- ${attn}\n"
"- ${street}\n"
- "- ${zip}\n"
+ "- ${postal_code}\n"
"- ${city}\n"
"- ${subdivision}\n"
"- ${subdivision_code}\n"
@@ -300,7 +306,7 @@ class AddressFormat(DeactivableMixin, MatchMixin, ModelSQL, ModelView):
return """${party_name}
${name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${subdivision}
${COUNTRY}"""
diff --git a/address.xml b/address.xml
index 9319b3a7d2..9222a59df8 100644
--- a/address.xml
+++ b/address.xml
@@ -147,7 +147,7 @@ this repository contains the full copyright notices and license terms. -->
${name}
${street}
${subdivision}
-${ZIP}, ${city}
+${POSTAL_CODE}, ${city}
${COUNTRY}
@@ -158,7 +158,7 @@ ${attn}
${name}
${street}
${subdivision}
-${CITY} ${SUBDIVISION} ${ZIP}
+${CITY} ${SUBDIVISION} ${POSTAL_CODE}
${COUNTRY}
@@ -168,7 +168,7 @@ ${COUNTRY}
${attn}
${name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -178,7 +178,7 @@ ${COUNTRY}
${attn}
${name}
${street}
-${city}-${zip}
+${city}-${postal_code}
${COUNTRY}
@@ -187,7 +187,7 @@ ${COUNTRY}
${party_name}
${name}
${street}
-${zip}, ${city}
+${postal_code}, ${city}
${subdivision}
${COUNTRY}
@@ -198,7 +198,7 @@ ${COUNTRY}
${party_name}
${name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -208,7 +208,7 @@ ${COUNTRY}
${street}
${name}
${city} - ${subdivision_code}
-${zip}
+${postal_code}
${COUNTRY}
@@ -217,7 +217,7 @@ ${COUNTRY}
${party_name}
${street}
${name}
-${zip} ${city}
+${postal_code} ${city}
${subdivision}
${COUNTRY}
@@ -229,7 +229,7 @@ ${COUNTRY}
${party_name}
${name}
${street}
-${city} (${subdivision}) ${zip}
+${city} (${subdivision}) ${postal_code}
${COUNTRY}
@@ -239,7 +239,7 @@ ${COUNTRY}
${PARTY_NAME}
${NAME}
${STREET}
-${CITY} ${SUBDIVISION_CODE} ${ZIP}
+${CITY} ${SUBDIVISION_CODE} ${POSTAL_CODE}
${COUNTRY}
@@ -248,7 +248,7 @@ ${COUNTRY}
${party_name}
${street}
${name}
-${zip}
+${postal_code}
${city}
${COUNTRY}
@@ -256,14 +256,14 @@ ${COUNTRY}
CN
zh
- ${COUNTRY} ${ZIP}
+ ${COUNTRY} ${POSTAL_CODE}
${subdivision}${city}${street}${name}
${party_name}
CN
- ${COUNTRY} ${ZIP}
+ ${COUNTRY} ${POSTAL_CODE}
${subdivision}, ${city}, ${street}, ${name}
${party_name}
@@ -272,7 +272,7 @@ ${party_name}
HR
${party_name}
${street}
-${COUNTRY_CODE}-${ZIP} ${city}
+${COUNTRY_CODE}-${POSTAL_CODE} ${city}
${COUNTRY}
@@ -281,7 +281,7 @@ ${COUNTRY}
${party_name}
${attn}
${street}
-${COUNTRY_CODE}-${ZIP} ${city}
+${COUNTRY_CODE}-${POSTAL_CODE} ${city}
${COUNTRY}
@@ -289,7 +289,7 @@ ${COUNTRY}
DK
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -297,7 +297,7 @@ ${COUNTRY}
EE
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -306,7 +306,7 @@ ${COUNTRY}
${attn}
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -316,7 +316,7 @@ ${COUNTRY}
${attn}
${name}
${street}
-${ZIP} ${CITY}
+${POSTAL_CODE} ${CITY}
${COUNTRY}
@@ -326,7 +326,7 @@ ${COUNTRY}
${attn}
${name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -334,7 +334,7 @@ ${COUNTRY}
GR
${party_name}
${street}
-${COUNTRY_CODE}-${ZIP} ${CITY}
+${COUNTRY_CODE}-${POSTAL_CODE} ${CITY}
${COUNTRY}
@@ -352,7 +352,7 @@ ${COUNTRY}
${party_name}
${city}
${street}
-${zip}
+${postal_code}
${COUNTRY}
@@ -361,7 +361,7 @@ ${COUNTRY}
${party_name}
${street}
${name}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -370,7 +370,7 @@ ${COUNTRY}
${party_name}
${name}
${street}
-${CITY} ${zip}
+${CITY} ${postal_code}
${subdivision}
${COUNTRY}
@@ -380,7 +380,7 @@ ${COUNTRY}
${party_name}
${name}
${street}
-${city} ${zip}
+${city} ${postal_code}
${subdivision}
${COUNTRY}
@@ -397,7 +397,7 @@ ${name}
${city}
${street}
${subdivision}
-${zip}
+${postal_code}
${COUNTRY}
@@ -407,7 +407,7 @@ ${COUNTRY}
${street}
${name}
${subdivision}
-${zip}
+${postal_code}
${COUNTRY}
@@ -415,7 +415,7 @@ ${COUNTRY}
IE
${party_name}
${street}
-${city} ${zip}
+${city} ${postal_code}
${COUNTRY}
@@ -423,7 +423,7 @@ ${COUNTRY}
IL
${party_name}
${street}
-${city} ${zip}
+${city} ${postal_code}
${COUNTRY}
@@ -433,7 +433,7 @@ ${COUNTRY}
${attn}
${name}
${street}
-${zip} ${city} ${SUBDIVISION_CODE}
+${postal_code} ${city} ${SUBDIVISION_CODE}
${COUNTRY}
@@ -446,7 +446,7 @@ ${COUNTRY}
JP
jp
${COUNTRY}
-${zip}
+${postal_code}
${subdivision}${city}${street}
${party_name}
@@ -455,7 +455,7 @@ ${party_name}
JP
${party_name}
${street}
-${city}, ${SUBDIVISION} ${zip}
+${city}, ${SUBDIVISION} ${postal_code}
${COUNTRY}
@@ -465,14 +465,14 @@ ${COUNTRY}
${COUNTRY}
${street}
${party_name}
-${zip}
+${postal_code}
KR
${party_name}
${street}
-${city}, ${subdivision} ${zip}
+${city}, ${subdivision} ${postal_code}
${COUNTRY}
@@ -482,7 +482,7 @@ ${COUNTRY}
${street}
${city}
${subdivision}
-${COUNTRY_CODE}-${ZIP}
+${COUNTRY_CODE}-${POSTAL_CODE}
${COUNTRY}
@@ -509,7 +509,7 @@ ${COUNTRY}
${party_name}
${name}
${street}
-${zip} ${CITY}
+${postal_code} ${CITY}
${SUBDIVISION}
${COUNTRY}
@@ -520,7 +520,7 @@ ${COUNTRY}
${party_name}
${street}
${name}
-${zip}, ${city}, ${subdivision}
+${postal_code}, ${city}, ${subdivision}
${COUNTRY}
@@ -530,7 +530,7 @@ ${COUNTRY}
${attn}
${name}
${street}
-${zip} ${CITY}
+${postal_code} ${CITY}
${COUNTRY}
@@ -538,7 +538,7 @@ ${COUNTRY}
NZ
${party_name}
${street}
-${city} ${zip}
+${city} ${postal_code}
${COUNTRY}
@@ -546,7 +546,7 @@ ${COUNTRY}
NO
${party_name}
${street}
-${zip} ${CITY}
+${postal_code} ${CITY}
${COUNTRY}
@@ -563,7 +563,7 @@ ${COUNTRY}
${party_name}
${street}
${city}
-${zip}
+${postal_code}
${subdivision}
${COUNTRY}
@@ -582,7 +582,7 @@ ${COUNTRY}
PH
${party_name}
${street}
-${zip} ${CITY}
+${postal_code} ${CITY}
${COUNTRY}
@@ -590,7 +590,7 @@ ${COUNTRY}
PL
${attn} ${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -598,7 +598,7 @@ ${COUNTRY}
PT
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -615,7 +615,7 @@ ${COUNTRY}
${attn} ${party_name}
${street}
${city}
-${zip}
+${postal_code}
${COUNTRY}
@@ -626,14 +626,14 @@ ${street}
${city}
${subdivision}
${COUNTRY}
-${zip}
+${postal_code}
SA
${party_name}
${street}
-${city} ${zip}
+${city} ${postal_code}
${COUNTRY}
@@ -641,7 +641,7 @@ ${COUNTRY}
RS
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -650,7 +650,7 @@ ${COUNTRY}
${party_name}
${street}
${name}
-${CITY} ${ZIP}
+${CITY} ${POSTAL_CODE}
${COUNTRY}
@@ -659,7 +659,7 @@ ${COUNTRY}
${attn}
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -668,7 +668,7 @@ ${COUNTRY}
${party_name}
${attn}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -676,7 +676,7 @@ ${COUNTRY}
ES
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${subdivision}
${COUNTRY}
@@ -691,7 +691,7 @@ ${COUNTRY}
${party_name}
${street}
${CITY}
-${zip}
+${postal_code}
${COUNTRY}
@@ -699,7 +699,7 @@ ${COUNTRY}
SE
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -707,7 +707,7 @@ ${COUNTRY}
CH
${party_name}
${street}
-${zip} ${city}
+${postal_code} ${city}
${COUNTRY}
@@ -715,7 +715,7 @@ ${COUNTRY}
TW
zh
${COUNTRY}
-${zip}
+${postal_code}
${street}
${party_name}
@@ -724,7 +724,7 @@ ${party_name}
TW
${party_name}
${street}
-${city}, ${subdivision} ${zip}
+${city}, ${subdivision} ${postal_code}
${COUNTRY}
@@ -735,7 +735,7 @@ ${street}
${name}
${subdivision}
${COUNTRY}
-${zip}
+${postal_code}
@@ -744,7 +744,7 @@ ${zip}
${attn}
${street}
${name}
-${zip} ${city} ${subdivision}
+${postal_code} ${city} ${subdivision}
${COUNTRY}
@@ -754,7 +754,7 @@ ${COUNTRY}
${street}
${city}
${subdivision}
-${zip}
+${postal_code}
${COUNTRY}
@@ -763,7 +763,7 @@ ${COUNTRY}
${party_name}
${street}
${CITY}
-${zip}
+${postal_code}
${COUNTRY}
@@ -772,7 +772,7 @@ ${COUNTRY}
${attn}
${party_name}
${street}
-${city}, ${subdivision_code} ${zip}
+${city}, ${subdivision_code} ${postal_code}
${COUNTRY}
diff --git a/party.py b/party.py
index ab077ca536..4c391161a4 100644
--- a/party.py
+++ b/party.py
@@ -862,7 +862,8 @@ class Erase(Wizard):
['type', 'code'],
[None, '****']),
(Address, [('party', '=', party_id)], True,
- ['name', 'street', 'zip', 'city', 'country', 'subdivision'],
+ ['name', 'street', 'postal_code', 'city',
+ 'country', 'subdivision'],
[None, None, None, None, None, None]),
(ContactMechanism, [('party', '=', party_id)], True,
['value', 'name', 'comment'],
diff --git a/tests/test_party.py b/tests/test_party.py
index 720a5d8be1..3fa2c708fe 100644
--- a/tests/test_party.py
+++ b/tests/test_party.py
@@ -215,14 +215,14 @@ class PartyTestCase(PartyCheckEraseMixin, ModuleTestCase):
address1, address2 = Address.create([{
'party': party.id,
'sequence': 1,
- 'zip': None,
+ 'postal_code': None,
}, {
'party': party.id,
'sequence': 2,
- 'zip': '1000',
+ 'postal_code': '1000',
}])
- address = party.address_get(type='zip')
+ address = party.address_get(type='postal_code')
self.assertEqual(address, address2)
diff --git a/view/address_form.xml b/view/address_form.xml
index 68b0272ebb..4b1f5a83cc 100644
--- a/view/address_form.xml
+++ b/view/address_form.xml
@@ -21,8 +21,8 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
diff --git a/view/address_tree.xml b/view/address_tree.xml
index 5bbb961b35..f2ba86c3a6 100644
--- a/view/address_tree.xml
+++ b/view/address_tree.xml
@@ -5,7 +5,7 @@ this repository contains the full copyright notices and license terms. -->
-
+
diff --git a/view/address_tree_sequence.xml b/view/address_tree_sequence.xml
index ed6e26ff9e..bf6934d4ca 100644
--- a/view/address_tree_sequence.xml
+++ b/view/address_tree_sequence.xml
@@ -5,7 +5,7 @@ this repository contains the full copyright notices and license terms. -->
-
+