The value "district with special status" for field "Type" in "Subdivision" is not one of the allowed options
Since pycountry==22.1.10 [1] when try to import countries, crash with error:
The value "district with special status" for field "Type" in "Subdivision" is not one of the allowed options
The traceback:
$ ./trytond/trytond/modules/country/scripts/import_countries.py -c etc/server-montcau.cfg -d nan54country
Update countries
Update subdivisions
Traceback (most recent call last):
File "./trytond/trytond/modules/country/scripts/import_countries.py", line 177, in <module>
run()
File "./trytond/trytond/modules/country/scripts/import_countries.py", line 173, in run
main(args.database, args.config_file)
File "./trytond/trytond/modules/country/scripts/import_countries.py", line 151, in main
do_import()
File "./trytond/trytond/modules/country/scripts/import_countries.py", line 159, in do_import
subdivisions = update_subdivisions(countries, subdivisions)
File "./trytond/trytond/modules/country/scripts/import_countries.py", line 105, in update_subdivisions
Subdivision.save(records)
File "/home/raimon/projectes/nandev/demo/proteus/proteus/__init__.py", line 103, in newfunc
return self.func(owner, *args, **kwargs)
File "/home/raimon/projectes/nandev/demo/proteus/proteus/__init__.py", line 847, in save
ids = proxy.create(values, context)
File "/home/raimon/projectes/nandev/demo/proteus/proteus/config.py", line 188, in __call__
result = rpc.result(meth(*args, **kwargs))
File "/home/raimon/projectes/nandev/demo/trytond/trytond/modules/country/country.py", line 241, in create
return super(Subdivision, cls).create(vlist)
File "/home/raimon/projectes/nandev/demo/trytond/trytond/model/modelsql.py", line 159, in wrapper
return func(cls, *args, **kwargs)
File "/home/raimon/projectes/nandev/demo/trytond/trytond/model/modelsql.py", line 677, in create
cls._validate(sub_records)
File "/home/raimon/projectes/nandev/demo/trytond/trytond/model/modelstorage.py", line 75, in wrapper
return func(*args, **kwargs)
File "/home/raimon/projectes/nandev/demo/trytond/trytond/model/modelstorage.py", line 1295, in _validate
**error_args))
trytond.model.modelstorage.SelectionValidationError: The value "district with special status" for field "Type" in "Subdivision" is not one of the allowed options. -
Since pycountry (changeset d8ea221 - Import data for iso-codes v4.8.0) [2], add new subdivision type: district with special status (pycountry/databases/iso3166-2.json)
Example:
{
"code": "BA-BRC",
"name": "Brčko distrikt",
"type": "District with special status"
},
[1] https://pypi.org/project/pycountry/22.1.10/ [2] https://github.com/flyingcircusio/pycountry/commit/d8ea221b9f888a803715c294c2eeb194ad1462e4