changeset 34ddf82ded53 in modules/web_shop_shopify:6.2 details: https://hg.tryton.org/modules/web_shop_shopify?cmd=changeset&node=34ddf82ded53 description: Ignore subdivision with non valid type
issue11201 review381901002 (grafted from 240c671c6be761788b7357eac42fd75fdb8a1e9f) diffstat: party.py | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diffs (30 lines): diff -r 3f6bacdd465a -r 34ddf82ded53 party.py --- a/party.py Sat Jan 15 16:22:57 2022 +0100 +++ b/party.py Mon Feb 07 22:41:11 2022 +0100 @@ -59,6 +59,7 @@ pool = Pool() Country = pool.get('country.country') Subdivision = pool.get('country.subdivision') + SubdivisionType = pool.get('party.address.subdivision_type') values = {} values['party_name'] = remove_forbidden_chars(address.name or '') @@ -75,10 +76,14 @@ if address.province_code: subdivision_code = '-'.join( [address.country_code, address.province_code]) - subdivisions = Subdivision.search([ - ('country', '=', country.id), - ('code', 'like', subdivision_code + '%'), - ], limit=1) + subdivision_domain = [ + ('country', '=', country.id), + ('code', 'like', subdivision_code + '%'), + ] + types = SubdivisionType.get_types(country) + if types: + subdivision_domain.append(('type', 'in', types)) + subdivisions = Subdivision.search(subdivision_domain, limit=1) if subdivisions: subdivision, = subdivisions values['subdivision'] = subdivision.id