Odoo 19 is a powerful and comprehensive ERP software. However, while working through new features or customizations, it's natural that you will encounter bugs from time to time. Actually, errors represent the inevitable nature of the product cycle. Making a module from scratch, changing the functionality of an existing one, or just fixing a problem for a user by tracing an error, all of these require an ability to track and identify errors. Therefore, one of the essential skills for an Odoo developer is knowing how to detect errors and follow their tracks.
Here are some common Odoo error types that you may encounter and also a time-tested debugging approach for you to handle them.
Reasons for tracing errors
Odoo even gives you some hints of the issue by showing you a traceback when an error occurs. You will save yourself a great deal of time on debugging if you learn how to interpret such messages, and you will find the error with less effort.
The debugging steps, generally, are:
- Read the error message carefully.
- Classify the error.
- Identify the file location and the line number where the error occurs.
- Look at the code, XML, security, or data that are associated with the error.
- Fix the error and verify the success of the fix.
Understanding Odoo tracebacks
Whenever one or more exceptions occur, Odoo raises tracebacks in the server log or terminal.
Example:
ValueError: Invalid field 'customer_id' on model 'sale.order'
Nevertheless, the most important pieces of information in a traceback are almost always the ones contained in the last lines. The last few lines usually hold the true cause of the error.
Common Error Types in Odoo 19
1. AccessError
This type of error occurs when a user without the necessary permissions tries to perform an operation.
Example:
AccessError: You are not allowed to access this document.
Main Causes
- Lack of correct ACL permissions
- Record rules with very restrictive conditions
- Incorrect user group assignments
What Changes You Must Look At
- Access Control Lists
- Record Rules
- User roles and groups
2. ValidationError
This error code is generated when business rules are not followed.
Example:
raise ValidationError("Amount must be greater than zero.")
Main Causes
- Field values not done correctly
- Constraint violations
- Business logic checks
What Changes You Must Look At
- @api.constrains
- Custom validation methods
- Create and write operations
3. UserError
UserError is a means to let the user know that the wrong operation has been done.
Example:
raise UserError("Please add at least one order line.")
Main Causes
- Some of the required data are missing
- Actions of the workflow have been triggered wrongly
- User operations are not valid
4. ValueError
ValueError is used with wrong value or field.
Example:
ValueError: Invalid field 'partner_ids'
Main Causes
- Field names mistyped
- The wrong model has been referred
- ORM operations are invalid
5. ParseError
ParseError gives a good sign about the problems in xml files.
Example:
ParseError:Field 'customer_code' does not exist
Main Causes
- Errors in XML syntax
- Not having closing tags
- XPath expressions that are wrong
- Fields missing in views
What Changes You Must Look At.
- XML view files
- Menu definitions
- Security files
6. OwlError
Since the frontend components of Odoo 19 are based on the OWL framework, a problem in JavaScript or OWL components would cause OwlError.
Example:
OwlError: Invalid props
Main Causes
- Component properties are invalid
- Errors in JavaScript
- OWL patches are incorrect
What Changes You Must Look At
- Browser console (F12)
- Custom JavaScript code
- OWL component definitions
Error handling and debugging are essential skills for Odoo developers. By understanding common error types such as AccessError, ValidationError, ParseError, RPC_ERROR, and OwlError, you can quickly identify the problem and resolve it efficiently. Instead of focusing only on the error message, learn to analyze the traceback, inspect logs, review security settings, and verify your code. Following a structured debugging approach will help you solve issues faster, improve code quality, and make Odoo development much more productive.
7. RPC_ERROR (Remote Procedure Call Error)
If a backend exception is carried to the frontend RPC_ERROR will be shown on the web interface.
The true cause is usually found in the server log and it can be an AccessError, ValidationError, ValueError, or other backend exceptions.
What to Do
Server logs should always be your first reference for the complete traceback.
To read more about Overview of Error Management in Odoo 19, refer to our blog Overview of Error Management in Odoo 19.