0
我需要列出法語的所有國家。列出特定語言的所有國家
all_countries = self.env['res.country'].search([])
for country in all_countries:
_logger.error(country.name)
有了這段代碼,我得到了國家英文名稱。如何獲得法文嗎?
我需要列出法語的所有國家。列出特定語言的所有國家
all_countries = self.env['res.country'].search([])
for country in all_countries:
_logger.error(country.name)
有了這段代碼,我得到了國家英文名稱。如何獲得法文嗎?
據我所知,國家和語言之間沒有提及。您必須通過外部模塊獲取列表。嘗試pycountry(https://pypi.python.org/pypi/pycountry/0.12.1),獲取國家代碼列表(通過語言代碼fr- *),然後在res.country中搜索匹配項。
或者你可以覆蓋res.country並添加語言引用你自己:)