ValueError: Expected singleton: website()
This question has been flagged
Hi Vo Nguyen Phuc Ngan,
This looks like a website module configuration issue in Odoo 18 — the restored database has a conflict with the website records.
What's causing this error?
When you restored the database, Odoo found multiple website records where it expected only one (a "singleton"). This commonly happens when:
- The source and destination databases had different website configurations
- The restore process duplicated website records
How to fix it
- Go to Settings → activate Developer Mode (add ?debug=1 to URL)
- Navigate to Website → Configuration → Websites
- Delete or archive any duplicate website entries, keeping only one
Option 2: Fix via PostgreSQL directly
sql
-- Connect to your database
psql -d YOUR_DATABASE_NAME
-- Check website records
SELECT id, name, domain, active FROM website;
-- If duplicates exist, deactivate all but the first
UPDATE website SET active = false WHERE id NOT IN (
SELECT MIN(id) FROM website
);
Open a terminal in your Odoo directory and run:
python odoo-bin shell -d YOUR_DATABASE_NAME
Then in the shell:
python
# Check how many website records exist
websites = env['website'].search([])
print(len(websites), websites)
# If there are duplicates, deactivate extras (keep only the first one)
for w in websites[1:]:
w.write({'active': False})
env.cr.commit()
Restart your Odoo server
bash
# Stop the server, then: python odoo-bin -d YOUR_DATABASE_NAME -u website
Quick question
When you run the shell command and check len(websites), how many records do you see? That'll confirm whether duplicates are the root cause.
If you have any questions, feel free to reach out.
Hope this helps!
Thanks and Regards,
Email: odoo@aktivsoftware.com
Hi Vo Nguyen Phuc Ngan,
The error you’re seeing:
ValueError: Expected singleton: website()
happens because Odoo is trying to process multiple records where it expects only one. In this case, the website model expects a single website record, but after restoring the database, there might be duplicate website records or an empty record set.
Why it happens after restoring a database:
Restoring the database may have created duplicate entries in website or related models.
Odoo’s website code often uses .ensure_one() to make sure only one record is being processed.
If it finds zero or more than one record, it throws this error.
How to fix it:
Step 1: Check the website records
Activate Developer Mode in Odoo.
Go to Website → Configuration → Websites.
Check if there are multiple websites listed or an empty one.
Step 2: Keep only one active website
Delete duplicates or empty websites.
Make sure exactly one website is active and properly configured.
Step 3: Check website_id in other models
Sometimes models like ir.config_parameter or website.page may reference a deleted or duplicate website.
You can check in Settings → Technical → Database Structure → Models → website if needed.
Step 4: Restart Odoo
After cleaning duplicates, restart the Odoo server.
Refresh the page and open your restored database.
Optional: If you are comfortable with PostgreSQL, you can verify duplicates directly:
SELECT id, name FROM website;
Keep only the correct one
Make a backup before deleting anything!
Hope it will solve your issue.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Hello,
It is not restored completely.. Remove that existing database and try to restore again and also check logs while restoring the database.