Skip to content

Instantly share code, notes, and snippets.

@mstuttgart
Last active November 19, 2024 21:05
Show Gist options
  • Save mstuttgart/d4f49c39e6dcd31e61814b7516f8b189 to your computer and use it in GitHub Desktop.
Save mstuttgart/d4f49c39e6dcd31e61814b7516f8b189 to your computer and use it in GitHub Desktop.
How to Reset the Odoo Admin User Password: A Summary for different Odoo Versions

Preliminary Remark

When you have migrated your database from an earlier version, the ID of your admin user may be different than suggested below. In this case you should check the ID of your admin user directly in the res_users table in your database.

Odoo 8.0:

Change the password directly in the Postgres Database, as it is saved in plain text:

~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# update res_users set password='YourNewPassword' where id='1';

Odoo 9.0 and Odoo 10.0:

Create a hash and then change the hash in the Postgres database:

~$ python
>>> from passlib.context import CryptContext
>>> print CryptContext(['pbkdf2_sha512']).encrypt('YourNewPassword')
Copy the Hash created
Ctrl D
~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# UPDATE res_users SET password='', password_crypt='YourCopiedHash' WHERE id=1;
YOurDatabase_Name=# \q

Odoo 11:

Create a hash using Python 3 and change the hash in the Postgres database:

~$ python3
>>> from passlib.context import CryptContext
>>> setpw = CryptContext(schemes=['pbkdf2_sha512'])
>>> setpw.encrypt('YourNewPassword')
Copy the Hash created
Ctrl D
~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# UPDATE res_users SET password='', password_crypt='YourCopiedHash' WHERE id=1;
YOurDatabase_Name=# \q

Odoo 12 and Odoo 13:

Create a hash using Python 3 and change the hash in the Postgres database:

~$ python3
>>> from passlib.context import CryptContext
>>> setpw = CryptContext(schemes=['pbkdf2_sha512'])
>>> setpw.encrypt('YourNewPassword')
Copy the Hash created
Ctrl D
~$  sudo su postgres
~$  psql
postgres=# \connect Your_Database_Name
You are now connected to database "Your_database_Name" as user "postgres"
YOurDatabase_Name=# UPDATE res_users SET password='YourCopiedHash' WHERE id=2;
YOurDatabase_Name=# \q

Please be aware that since Odoo12 the Primary Key of the admin user has changed. The new ID is 2 (not 1 as in earlier versions) in a new install, if you have migrated your database from an earlier version, it might be even a higher number - please check your res_users table in the database first in this case.

Also there is no separate field "password_crypt" anymore.

Enjoy your saved life and don't forget to upvote this little tutorial!

Original post: https://www.odoo.com/pt_BR/forum/ajuda-1/how-to-reset-the-odoo-admin-user-password-a-summary-for-different-odoo-versions-131992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment