Method Decorators in Odoo 17 [2024]

Cybrosys Technologies

26-06-2024

1. @api.model

Defines a method that does not depend on a specific record. Used for actions not tied to a particular instance.

Method Decorators in Odoo

2. @api.autovacuum

Automates maintenance tasks to ensure database health and performance. Ideal for regular clean-up processes.

Method Decorators in Odoo

3. @api.constrains

Validates conditions on field values. Ensures data integrity by enforcing rules during record creation or update.

Method Decorators in Odoo

4. @api.depends

Specifies dependencies for computed fields. Updates the field value when dependent fields change.

Method Decorators in Odoo

5. @api.model_create_multi

Allows creating multiple records in a single call. Enhances performance by reducing the number of database transactions.

Method Decorators in Odoo

6. @api.onchange

Triggers change when specific fields are modified. Useful for dynamic form updates and validations.

Method Decorators in Odoo

7. @api.ondelete

Defines actions to take when a record is deleted. Helps manage related records and maintain data consistency.

Method Decorators in Odoo

8. @api.returns

Specifies the return type of a method. Ensures proper data types and formats for method outputs.

Method Decorators in Odoo