'If we\'re creating a new account through a many2one, there are chances that we typed the account code
instead of its name. In that case, switch both fields values.'

@api.model
def default_get(self, default_fields):

    default_name = self._context.get('default_name')
    default_code = self._context.get('default_code')
    if (default_name and (not default_code)):
        try:
            default_code = int(default_name)
        except ValueError:
            pass
        if default_code:
            default_name = False
    contextual_self = self.with_context(default_name=default_name, default_code=default_code)
    return super(AccountAccount, contextual_self).default_get(default_fields)
