Enable Dark Mode!
By: Thasni CP

How to Fix the Common Errors in Odoo 16

Technical Odoo 16 Odoo Enterprises

In this blog, we will discuss the common errors we faced in Odoo 16. Various types of problems occur while customizing or building a module. Let's discuss the reasons for the error and how to fix it.

The errors are,

1. AttributeError: '_unknown' object has no attribute 'id'


This mistake can occur for a number of reasons, some of which are listed below.

 -> If we add a many2one field, but we didn’t add ‘product’ on 'depends' in the manifest file, then we get this error. for example

product_id = fields.Many2one('product.product', string="Product")
'depends': ['base', 'mail', 'sale_management','mrp'],

To solve this error, add ‘product’ on depends in the manifest file.

'depends': ['base', 'mail', 'sale_management', 'product', 'mrp'],

->If we define a Many2One field without a model, for example,

product_id = fields.Many2one(string="Product")

To solve this, please ensure we define a model inside a Many2One field like the code below.

product_id = fields.Many2one('product.product', string="Product")

->If we pass wrong data types, for example,

internal_reference = fields.Many2one(related='product_id.default_code',
                       string='Internal Reference')

In this line of code, the type of default_code is Char, but we called this field in a Many2One type field. So that we get this error, to fix this issue, update the code like below.

internal_reference = fields.Char(related='product_id.default_code',
                           string='Internal Reference')

2. lxml.etree.XMLSyntaxError: Opening and ending tag mismatch:


<field name="product_id"
      domain="[('detailed_type', '=', 'product')]"
      attrs="{'readonly': [('state', '!=', 'draft')]}">

This error happens when the tags in the XML are incorrect. In the code above, a field's closing tag is missing. To fix this problem, check the line that corresponds to the error and replace the opening and closing of the tag. Update the code like the one below.

<field name="product_id"
      domain="[('detailed_type', '=', 'product')]"
      attrs="{'readonly': [('state', '!=', 'draft')]}"/>

3. AssertionError: Element Odoo has extra content:


When we derive a non-attribute in fields, this issue happens. for instance,

<menuitem id="error_id" name="Errors" action="common_error_action"

We define a menu item with attributes in the line of code above. Some attributes are action, name, parent, and groups. To resolve this issue, we must make sure that we spelled the attributes correctly and that we defined the attributes that Odoo follows. Instead of groups, we defined groups, resulting in this error. The modified code, as seen below,

<menuitem id="error_id"

4. TypeError: 'int' object is not subscriptable


The error message "TypeError: 'int' object is not subscriptable" typically occurs in Python when you try to use subscript notation (using square brackets []) on an object that is not subscriptable, such as an integer (int). This error usually arises when you attempt to access an element or index of a non-iterable object. Example as follows,

def _onchange_product_id(self):
   bom = self.env['mrp.bom'].search(['product_tmpl_id', '=', self.product_tmpl_id.id])

In this on change method, we search for a bill of materials that has the product_tmpl_id in this model, but there is a syntax error in this search method when we use search() ORM methods, we want to define that search([(domain)]); otherwise, we get this error. To solve this issue, update the code like this,

def _onchange_product_id(self):
   bom = self.env['mrp.bom'].search([('product_tmpl_id', '=', self.product_tmpl_id.id)])

Another example,

value = self.quantity.value

Here, quantity is an integer field instead of an object, so we get this error.

5. IndexError: tuple index out of range:


The error message "IndexError: tuple index out of range" occurs in Python when you try to access an index in a tuple that is outside the valid range of indices. This error typically arises when you attempt to access an index that doesn't exist in the tuple. for example,

def _onchange_product_id(self):
   bom = self.env['mrp.bom'].search([()])

In this on-change function, the search method can’t find the value of (), so we get this error. We can update the code by adding any domain in the tuple or adding empty square brackets [] to get all the values.

def _onchange_product_id(self):
   bom =self.env['mrp.bom'].search([('product_tmpl_id', '=', self.product_tmpl_id.id)]) Or 
def _onchange_product_id(self):
   bom = self.env['mrp.bom'].search([])

6. TypeError: __init__() got multiple values for argument 'string'


In Odoo, the TypeError with the message "TypeError: init() got multiple values for argument 'string'" usually occurs when you provide multiple values for the string argument while initializing an object or defining a field.

The string argument is used to assign a human-readable label or name to a field in Odoo. It helps users understand the purpose or meaning of the field in the user interface. Typically, you would set the string argument when defining a field using Odoo's field types.

For example

internal_reference = fields.Char("Reference",related='product_id.default_code',string='Internal Reference')

In this code, here, we can see that two strings are defined, one with a “string” parameter and another without a “string” parameter. If we define a text in a field with quotes, Odoo indicates that it is a string. To solve this, make sure that we add a string only once in a field. Update the code like,

internal_reference = fields.Char(related='product_id.default_code',
              string='Internal Reference')

7. KeyError


In the context of Odoo, a KeyError occurs when working with Odoo models. Odoo models represent database tables or collections of records. When you encounter a KeyError related to a model, it typically means that you are trying to access or manipulate a field that does not exist on the model.

Here's an example of how a KeyError can occur when working with Odoo models:

The error indicates that KeyError: ‘production_lines’

simple_production_ids = fields.One2many('error.line','production_lines',

So the next step is to check whether the field exists or not in our model.

production_line = fields.Many2one('common.error')

In the provided code, the field name is ‘production_line’, but we give it in the One2many field as ‘production_lines’ so that we get this error. 

8. ValueError: Expected singleton:


"ValueError: Expected singleton in Odoo," typically occurs when working with Odoo's ORM (Object Relational Mapping) system. This error is raised when you try to access a single record, but the query returns multiple records instead.

In Odoo, when you perform a search or browse operation using the ORM, it returns a record set. A record set is a collection of records, even if it contains only one record. However, there are certain situations where you expect to work with a single record, and if the query returns multiple records, Odoo raises the "Expected singleton" error. Let's discuss how we get this error and how to resolve it.

As you can see in the above picture, the error returns a recordset of 'mrp.production'. Let's check with the example,

def _onchange_product_id(self):
   mrp_order = self.env['mrp.production'].search([])

In this onchange method, we try to print the name of each record of this model. When using Search() ORM, it will search in all the records. To resolve this, update the code like,

def _onchange_product_id(self):
   mrp_order = self.env['mrp.production'].search([])
   for order in mrp_order:

Inside the method, there is a for loop that iterates over all the records of the ‘mrp.production’ model, retrieves the name field of each record, and prints it.

9. PermissionError: [Errno 13] Permission denied:


The error message you're encountering, "PermissionError: [Errno 13] Permission denied," typically indicates that the user running the Odoo process does not have sufficient permissions to bind to the specified server address. To solve this problem,

Check the server address and port: Verify that the server address and port you're trying to bind to are correct and available. Make sure the address and port combination are not already in use by another application.

10. No matching record found for external id:


If you are encountering the error message "No matching record found for external ID" in Odoo, it typically means that the system is unable to locate the record you are referring to using the provided external ID. An external ID is a unique identifier assigned to a record in Odoo to allow for easy referencing and integration with external systems.

To fix this issue, we must ensure that the external id is provided correctly; else, Odoo will be able to access it. They can't find the group, as evidenced by the image, so we want to verify the manifest file.

data': [

In order to prevent this problem when Odoo is launched from trying to locate the groups in the access file, the code above demonstrates that we provide the access file first, followed by the security group file. Update the manifest file as follows to correct this:

data': [

In conclusion, understanding and addressing common errors in Odoo 16 is crucial for a smooth and efficient experience with the platform. We have explored several prevalent issues that users may encounter during implementation, customization, and usage. By recognizing these errors and their potential solutions, users can optimize their Odoo 16 instances and enhance their overall productivity.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message