I’m currently in the process of migrating data and accidentally truncated some tables, including res_user, which resulted in the deletion of the admin user.
Now, I keep getting this warning:
You are trying to read records “1” of “User” that don’t exist anymore.
Although I can still log in, this warning keeps showing up. Does anyone know how to recover or manually recreate the admin user?
In your case I would create a fresh database to have as a reference, then recreate the missing records using sql in your production database.
Personally I do now know if trytond-admin could fix anything in your case, maybe try to update the database using trytond-admin? reset the password using -p flag? but only after you make a backup.
From experience: Always create a backup before doing risky manual work on a database, including recreating the records manually.
psycopg2.errors.ForeignKeyViolation: insert or update on table “res_user-res_group” violates foreign key constraint “res_user-res_group_user_fkey”
DETAIL: Key (user)=(1) is not present in table “res_user”.
During handling of the above exception, another exception occurred:
File "PATH/trytond/trytond/model/modelsql.py", line 379, in __raise_integrity_error
raise ForeignKeyError(
trytond.model.modelsql.ForeignKeyError: The value "1" for field "User" in "User - Group" does not exist. -
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/path/trytond/trytond/convert.py", line 461, in parse_xmlstream
raise Exception("Error " + self.current_state()) from e
Exception: Error In tag record model res.user-res.group with id res.user_admin_group_admin.