Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: ISO 3166

Entity: res.country

Compute Method: _compute_codes

Inputs Method Outputs
  • code
for country in self:
            c = False
            for country_type in ["countries", "historic_countries"]:
                try:
                    c = getattr(pycountry, country_type).get(alpha_2=country.code)
                except KeyError:
                    c = getattr(pycountry, country_type).get(alpha2=country.code)
                if c:
                    break
            if c:
                country.code_alpha3 = getattr(c, "alpha_3", getattr(c, "alpha3", False))
                country.code_numeric = c.numeric
            else:
                country.code_alpha3 = False
                country.code_numeric = False

Back to entity