[Python] E 250320 13:48:06 odoo_btn_utils:212 There is no country named: 'Country'

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I am running into an issue on Odoo version 17.

    The issue is that I am trying to receive the country id from odoo based on my users selected country and I get the error:

    [E 250320 13:48:06 odoo_btn_utils:212] There is no country named: Lithuania


    This error appears on any kind of country and I am assuming that it could be due to wrong call to check the country, but can't figure out what to fix directly. I tried looking in our odoo to see the correct call for countries or to check countries that are available and they're codes, but sadly couldn't find it as well.

    Code that executes the country_id search:

    def get_country_id(country_name):
    try:
    countries = execute_model('res.country', 'search_read', [[['name', '=', country_name]]], {'fields': ['id', 'name']})
    except ValueError as e:
    logger.error(f"An error occurred while retrieving CountryID: {countries}")
    return get_general_error_message()
    if not countries:
    logger.error(f'There is no country named: {country_name}')
    return get_general_error_message()
    return countries[0]['id']

    Continue reading...

Compartilhe esta Página