changeset 4c4b15b51435 in modules/party:default details: https://hg.tryton.org/modules/party?cmd=changeset&node=4c4b15b51435 description: Rename zip into postal code
issue9853 review340411002 diffstat: CHANGELOG | 1 + address.py | 34 ++++++---- address.xml | 124 ++++++++++++++++++++-------------------- party.py | 3 +- tests/test_party.py | 6 +- view/address_form.xml | 4 +- view/address_tree.xml | 2 +- view/address_tree_sequence.xml | 2 +- 8 files changed, 92 insertions(+), 84 deletions(-) diffs (757 lines): diff -r 21b77510b21a -r 4c4b15b51435 CHANGELOG --- a/CHANGELOG Sun Mar 28 19:20:36 2021 +0200 +++ b/CHANGELOG Wed Mar 31 23:59:33 2021 +0200 @@ -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 -r 21b77510b21a -r 4c4b15b51435 address.py --- a/address.py Sun Mar 28 19:20:36 2021 +0200 +++ b/address.py Wed Mar 31 23:59:33 2021 +0200 @@ -34,7 +34,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ '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 @@ '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 @@ party, self.name, street, - self.zip, + self.postal_code, self.city, country])) @@ -199,7 +205,7 @@ ('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 @@ "- ${name}\n" "- ${attn}\n" "- ${street}\n" - "- ${zip}\n" + "- ${postal_code}\n" "- ${city}\n" "- ${subdivision}\n" "- ${subdivision_code}\n" @@ -300,7 +306,7 @@ return """${party_name} ${name} ${street} -${zip} ${city} +${postal_code} ${city} ${subdivision} ${COUNTRY}""" diff -r 21b77510b21a -r 4c4b15b51435 address.xml --- a/address.xml Sun Mar 28 19:20:36 2021 +0200 +++ b/address.xml Wed Mar 31 23:59:33 2021 +0200 @@ -147,7 +147,7 @@ ${name} ${street} ${subdivision} -${ZIP}, ${city} +${POSTAL_CODE}, ${city} ${COUNTRY}</field> </record> @@ -158,7 +158,7 @@ ${name} ${street} ${subdivision} -${CITY} ${SUBDIVISION} ${ZIP} +${CITY} ${SUBDIVISION} ${POSTAL_CODE} ${COUNTRY}</field> </record> @@ -168,7 +168,7 @@ ${attn} ${name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -178,7 +178,7 @@ ${attn} ${name} ${street} -${city}-${zip} +${city}-${postal_code} ${COUNTRY}</field> </record> @@ -187,7 +187,7 @@ <field name="format_">${party_name} ${name} ${street} -${zip}, ${city} +${postal_code}, ${city} ${subdivision} ${COUNTRY}</field> </record> @@ -198,7 +198,7 @@ ${party_name} ${name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -208,7 +208,7 @@ ${street} ${name} ${city} - ${subdivision_code} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -217,7 +217,7 @@ <field name="format_">${party_name} ${street} ${name} -${zip} ${city} +${postal_code} ${city} ${subdivision} ${COUNTRY}</field> </record> @@ -229,7 +229,7 @@ ${party_name} ${name} ${street} -${city} (${subdivision}) ${zip} +${city} (${subdivision}) ${postal_code} ${COUNTRY}</field> </record> @@ -239,7 +239,7 @@ ${PARTY_NAME} ${NAME} ${STREET} -${CITY} ${SUBDIVISION_CODE} ${ZIP} +${CITY} ${SUBDIVISION_CODE} ${POSTAL_CODE} ${COUNTRY}</field> </record> @@ -248,7 +248,7 @@ <field name="format_">${party_name} ${street} ${name} -${zip} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -256,14 +256,14 @@ <record model="party.address.format" id="address_format_cn_zh_CN"> <field name="country_code">CN</field> <field name="language_code">zh</field> - <field name="format_">${COUNTRY} ${ZIP} + <field name="format_">${COUNTRY} ${POSTAL_CODE} ${subdivision}${city}${street}${name} ${party_name}</field> </record> <record model="party.address.format" id="address_format_cn"> <field name="country_code">CN</field> - <field name="format_">${COUNTRY} ${ZIP} + <field name="format_">${COUNTRY} ${POSTAL_CODE} ${subdivision}, ${city}, ${street}, ${name} ${party_name}</field> </record> @@ -272,7 +272,7 @@ <field name="country_code">HR</field> <field name="format_">${party_name} ${street} -${COUNTRY_CODE}-${ZIP} ${city} +${COUNTRY_CODE}-${POSTAL_CODE} ${city} ${COUNTRY}</field> </record> @@ -281,7 +281,7 @@ <field name="format_">${party_name} ${attn} ${street} -${COUNTRY_CODE}-${ZIP} ${city} +${COUNTRY_CODE}-${POSTAL_CODE} ${city} ${COUNTRY}</field> </record> @@ -289,7 +289,7 @@ <field name="country_code">DK</field> <field name="format_">${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -297,7 +297,7 @@ <field name="country_code">EE</field> <field name="format_">${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -306,7 +306,7 @@ <field name="format_">${attn} ${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -316,7 +316,7 @@ ${attn} ${name} ${street} -${ZIP} ${CITY} +${POSTAL_CODE} ${CITY} ${COUNTRY}</field> </record> @@ -326,7 +326,7 @@ ${attn} ${name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -334,7 +334,7 @@ <field name="country_code">GR</field> <field name="format_">${party_name} ${street} -${COUNTRY_CODE}-${ZIP} ${CITY} +${COUNTRY_CODE}-${POSTAL_CODE} ${CITY} ${COUNTRY}</field> </record> @@ -352,7 +352,7 @@ <field name="format_">${party_name} ${city} ${street} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -361,7 +361,7 @@ <field name="format_">${party_name} ${street} ${name} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -370,7 +370,7 @@ <field name="format_">${party_name} ${name} ${street} -${CITY} ${zip} +${CITY} ${postal_code} ${subdivision} ${COUNTRY}</field> </record> @@ -380,7 +380,7 @@ <field name="format_">${party_name} ${name} ${street} -${city} ${zip} +${city} ${postal_code} ${subdivision} ${COUNTRY}</field> </record> @@ -397,7 +397,7 @@ ${city} ${street} ${subdivision} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -407,7 +407,7 @@ ${street} ${name} ${subdivision} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -415,7 +415,7 @@ <field name="country_code">IE</field> <field name="format_">${party_name} ${street} -${city} ${zip} +${city} ${postal_code} ${COUNTRY}</field> </record> @@ -423,7 +423,7 @@ <field name="country_code">IL</field> <field name="format_">${party_name} ${street} -${city} ${zip} +${city} ${postal_code} ${COUNTRY}</field> </record> @@ -433,7 +433,7 @@ ${attn} ${name} ${street} -${zip} ${city} ${SUBDIVISION_CODE} +${postal_code} ${city} ${SUBDIVISION_CODE} ${COUNTRY}</field> </record> @@ -446,7 +446,7 @@ <field name="country_code">JP</field> <field name="language_code">jp</field> <field name="format_">${COUNTRY} -${zip} +${postal_code} ${subdivision}${city}${street} ${party_name}</field> </record> @@ -455,7 +455,7 @@ <field name="country_code">JP</field> <field name="format_">${party_name} ${street} -${city}, ${SUBDIVISION} ${zip} +${city}, ${SUBDIVISION} ${postal_code} ${COUNTRY}</field> </record> @@ -465,14 +465,14 @@ <field name="format_">${COUNTRY} ${street} ${party_name} -${zip}</field> +${postal_code}</field> </record> <record model="party.address.format" id="address_format_kr"> <field name="country_code">KR</field> <field name="format_">${party_name} ${street} -${city}, ${subdivision} ${zip} +${city}, ${subdivision} ${postal_code} ${COUNTRY}</field> </record> @@ -482,7 +482,7 @@ ${street} ${city} ${subdivision} -${COUNTRY_CODE}-${ZIP} +${COUNTRY_CODE}-${POSTAL_CODE} ${COUNTRY}</field> </record> @@ -509,7 +509,7 @@ ${party_name} ${name} ${street} -${zip} ${CITY} +${postal_code} ${CITY} ${SUBDIVISION} ${COUNTRY}</field> </record> @@ -520,7 +520,7 @@ ${party_name} ${street} ${name} -${zip}, ${city}, ${subdivision} +${postal_code}, ${city}, ${subdivision} ${COUNTRY}</field> </record> @@ -530,7 +530,7 @@ ${attn} ${name} ${street} -${zip} ${CITY} +${postal_code} ${CITY} ${COUNTRY}</field> </record> @@ -538,7 +538,7 @@ <field name="country_code">NZ</field> <field name="format_">${party_name} ${street} -${city} ${zip} +${city} ${postal_code} ${COUNTRY}</field> </record> @@ -546,7 +546,7 @@ <field name="country_code">NO</field> <field name="format_">${party_name} ${street} -${zip} ${CITY} +${postal_code} ${CITY} ${COUNTRY}</field> </record> @@ -563,7 +563,7 @@ <field name="format_">${party_name} ${street} ${city} -${zip} +${postal_code} ${subdivision} ${COUNTRY}</field> </record> @@ -582,7 +582,7 @@ <field name="country_code">PH</field> <field name="format_">${party_name} ${street} -${zip} ${CITY} +${postal_code} ${CITY} ${COUNTRY}</field> </record> @@ -590,7 +590,7 @@ <field name="country_code">PL</field> <field name="format_">${attn} ${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -598,7 +598,7 @@ <field name="country_code">PT</field> <field name="format_">${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -615,7 +615,7 @@ <field name="format_">${attn} ${party_name} ${street} ${city} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -626,14 +626,14 @@ ${city} ${subdivision} ${COUNTRY} -${zip}</field> +${postal_code}</field> </record> <record model="party.address.format" id="address_format_sa"> <field name="country_code">SA</field> <field name="format_">${party_name} ${street} -${city} ${zip} +${city} ${postal_code} ${COUNTRY}</field> </record> @@ -641,7 +641,7 @@ <field name="country_code">RS</field> <field name="format_">${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -650,7 +650,7 @@ <field name="format_">${party_name} ${street} ${name} -${CITY} ${ZIP} +${CITY} ${POSTAL_CODE} ${COUNTRY}</field> </record> @@ -659,7 +659,7 @@ <field name="format_">${attn} ${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -668,7 +668,7 @@ <field name="format_">${party_name} ${attn} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -676,7 +676,7 @@ <field name="country_code">ES</field> <field name="format_">${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${subdivision} ${COUNTRY}</field> </record> @@ -691,7 +691,7 @@ <field name="format_">${party_name} ${street} ${CITY} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -699,7 +699,7 @@ <field name="country_code">SE</field> <field name="format_">${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -707,7 +707,7 @@ <field name="country_code">CH</field> <field name="format_">${party_name} ${street} -${zip} ${city} +${postal_code} ${city} ${COUNTRY}</field> </record> @@ -715,7 +715,7 @@ <field name="country_code">TW</field> <field name="language_code">zh</field> <field name="format_">${COUNTRY} -${zip} +${postal_code} ${street} ${party_name}</field> </record> @@ -724,7 +724,7 @@ <field name="country_code">TW</field> <field name="format_">${party_name} ${street} -${city}, ${subdivision} ${zip} +${city}, ${subdivision} ${postal_code} ${COUNTRY}</field> </record> @@ -735,7 +735,7 @@ ${name} ${subdivision} ${COUNTRY} -${zip}</field> +${postal_code}</field> </record> <record model="party.address.format" id="address_format_tr"> @@ -744,7 +744,7 @@ ${attn} ${street} ${name} -${zip} ${city} ${subdivision} +${postal_code} ${city} ${subdivision} ${COUNTRY}</field> </record> @@ -754,7 +754,7 @@ ${street} ${city} ${subdivision} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -763,7 +763,7 @@ <field name="format_">${party_name} ${street} ${CITY} -${zip} +${postal_code} ${COUNTRY}</field> </record> @@ -772,7 +772,7 @@ <field name="format_">${attn} ${party_name} ${street} -${city}, ${subdivision_code} ${zip} +${city}, ${subdivision_code} ${postal_code} ${COUNTRY}</field> </record> diff -r 21b77510b21a -r 4c4b15b51435 party.py --- a/party.py Sun Mar 28 19:20:36 2021 +0200 +++ b/party.py Wed Mar 31 23:59:33 2021 +0200 @@ -862,7 +862,8 @@ ['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 -r 21b77510b21a -r 4c4b15b51435 tests/test_party.py --- a/tests/test_party.py Sun Mar 28 19:20:36 2021 +0200 +++ b/tests/test_party.py Wed Mar 31 23:59:33 2021 +0200 @@ -215,14 +215,14 @@ 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 -r 21b77510b21a -r 4c4b15b51435 view/address_form.xml --- a/view/address_form.xml Sun Mar 28 19:20:36 2021 +0200 +++ b/view/address_form.xml Wed Mar 31 23:59:33 2021 +0200 @@ -21,8 +21,8 @@ <label name="street"/> <field name="street" colspan="3"/> <newline/> - <label name="zip"/> - <field name="zip"/> + <label name="postal_code"/> + <field name="postal_code"/> <label name="city"/> <field name="city"/> <newline/> diff -r 21b77510b21a -r 4c4b15b51435 view/address_tree.xml --- a/view/address_tree.xml Sun Mar 28 19:20:36 2021 +0200 +++ b/view/address_tree.xml Wed Mar 31 23:59:33 2021 +0200 @@ -5,7 +5,7 @@ <field name="party" expand="2"/> <field name="party_name"/> <field name="name"/> - <field name="zip"/> + <field name="postal_code"/> <field name="city"/> <field name="country"/> <field name="subdivision"/> diff -r 21b77510b21a -r 4c4b15b51435 view/address_tree_sequence.xml --- a/view/address_tree_sequence.xml Sun Mar 28 19:20:36 2021 +0200 +++ b/view/address_tree_sequence.xml Wed Mar 31 23:59:33 2021 +0200 @@ -5,7 +5,7 @@ <field name="party" expand="2"/> <field name="party_name"/> <field name="name"/> - <field name="zip"/> + <field name="postal_code"/> <field name="city"/> <field name="country"/> <field name="subdivision" expand="1"/>