The problem
When working with Odoo, you may occasionally encounter issues with web assets becoming corrupted. This can manifest as missing styles, broken JavaScript functionality, or general UI problems that persist even after clearing your browser cache. These issues often occur after module updates or system changes.
The root cause is typically related to how Odoo bundles and caches CSS and JavaScript assets. When these get out of sync or corrupted, they need to be regenerated, but the Odoo interface might be too broken to use the built-in regeneration tools.
Solution overview
We'll solve this problem by:
- Connecting directly to the PostgreSQL database
- Locating and removing the corrupted asset records
- Restarting the Odoo container to force asset regeneration
This approach bypasses the UI entirely, allowing you to fix the problem even when the interface is unusable.
Prerequisites
- Access to the Docker environment running your Odoo instance
- Basic familiarity with PostgreSQL commands
- Terminal access to the server hosting Docker
Regenerating Odoo assets step by step
1. Connect to the PostgreSQL database
First, we need to identify and connect to the correct database. We'll use Docker commands to execute PostgreSQL client operations:
# Connect to the PostgreSQL container
docker exec -ti odoo_db_1 psql -d postgres -U odoo
# List available databases to find the correct one
docker exec odoo_db_1 psql -U odoo -l
This command will show output similar to:
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
-----------+-------+----------+------------+------------+------------+-----------------+-------------------
postgres | odoo | UTF8 | en_US.utf8 | en_US.utf8 | | libc |
template0 | odoo | UTF8 | en_US.utf8 | en_US.utf8 | | libc | =c/odoo +
| | | | | | | odoo=CTc/odoo
template1 | odoo | UTF8 | en_US.utf8 | en_US.utf8 | | libc | =c/odoo +
| | | | | | | odoo=CTc/odoo
test01 | odoo | UTF8 | C | en_US.utf8 | | libc |
Now switch to your Odoo database (in this example, it's "test01"):
postgres=# \c test01
You are now connected to database "test01" as user "odoo".
2. Identify asset records in the database
Odoo stores its web assets in the ir_attachment table. We need to find all the asset records:
test01=# select id, name from ir_attachment where res_model='ir.ui.view' and name like '%assets_%';
This query returns all asset-related attachments. You'll see an output listing all the CSS, JavaScript, and map files that make up Odoo's web interface.
Note
3. Delete all asset records
Now that we've identified the assets, we can delete them from the database:
test01=# delete from ir_attachment where res_model='ir.ui.view' and name like '%assets_%';
DELETE 45
The output shows how many records were deleted. In this example, 45 asset records were removed.
Warning
4. Restart the Odoo container
Exit from the PostgreSQL client by typing \q and press Enter. Then, restart your Odoo containers:
docker-compose down && docker-compose up -d
This command stops all the containers defined in your docker-compose.yml file and then starts them again in detached mode.
5. Verify the fix
Now open your browser and navigate to your Odoo instance. The first load might take a bit longer as Odoo regenerates all the assets, but the interface should now display correctly with all styles and JavaScript functionality restored.
Troubleshooting
If you still experience issues after following these steps, consider:
- Checking the Odoo logs for any errors during asset regeneration:
docker logs odoo_web_1 - Clearing your browser cache completely
- Verifying that all containers are running properly:
docker-compose ps
When to use this approach
This technique is particularly useful in the following scenarios:
- After upgrading Odoo or installing new modules
- When the Odoo interface becomes unusable due to CSS or JavaScript errors
- When you see browser console errors related to missing assets
- As a last resort when normal cache clearing doesn't resolve UI issues
Resources
- PostgreSQL command-line interface documentation
- Docker documentation
- Odoo developer documentation on assets
Tip