Solving "Assets Not Found" Error in Odoo Database UI

"Assets Not Found" Error in Odoo

by Dharmesh Patel

Encountering an "assets not found" error when loading the Odoo database UI can be frustrating. In this article, we'll explore a solution that involves creating an attachment for the asset bundle using Odoo's XML-RPC capabilities. I'll also provide the Odoo XML-RPC code for creating this attachment.

When attempting to load the Odoo database UI, users may sometimes face an error message indicating that assets are not found. This can disrupt the user experience and hinder productivity. Fortunately, there's a straightforward solution using Odoo's XML-RPC functionality.

Creating an Attachment for the Asset Bundle

Below is the Odoo XML-RPC code that demonstrates how to create an attachment for the asset bundle:

import xmlrpc.client
import base64

# Configuration
url =
"Your-Odoo-Instance-URL"
db =
"Your-odoo-db"
username =
"your-user-login"
password =
"your-user-pwd"

# Authenticate
common = xmlrpc.client.ServerProxy(f
"{url}/xmlrpc/2/common")
uid = common.authenticate(db, username, password, {})

# Prepare the attachment
models = xmlrpc.client.ServerProxy(f
"{url}/xmlrpc/2/object")
file_path =
"/home/dharmesh/Downloads/web.assets_web.min.js" # This change with your file path
file_name =
"web.assets_web.min.js"
model_name = 'ir.ui.view'
res_id = 0
url = '/web/assets/64d046d/web.assets_web.min.js'

# Read the file
with open(file_path,
"rb") as file:
file_content = file.read()
file_content_encoded = base64.b64encode(file_content)

# Create the attachment
attachment_id = models.execute_kw(
        db, uid, password,
        'ir.attachment', 'create', [{
        'name': file_name,
        'type': 'binary',
        'datas': file_content_encoded.decode(
"utf-8"),
        'res_model': model_name,
        'res_id': res_id,
        'company_id': 1,
        'url': url,
        'public': 1,
        }]
)

print(f
"Attachment created with ID: {attachment_id}")

By following this approach and utilizing Odoo's XML-RPC capabilities, you can resolve the "assets not found" error in the Odoo database UI effectively. Incorporate this code into your workflow to enhance the stability and functionality of your Odoo implementation.

Odoo 16 vs Odoo 17: Exploring New Features and Upgrades