Odoo 17 Development Book- Creating Records

Creating Records

The create() function generates new records for a specific model. These new records are initialized using values from the list of dictionaries (vals list) and, if required, those from the default get() function.


Values for fields are provided as a list of dictionaries for the model, structured like:

[{'field_name': field_value, ...}, ...]


partner = self.env['res.partner'].create({
     'name':'Test Partner',
An AccessError is raised in the following scenarios:

● When the user lacks the necessary permissions to grant access to the requested item.

● If the user attempts to circumvent access rules while creating the desired object.

A ValidationError is raised in the following scenarios:

● If a user attempts to input an invalid value for a non-selection field.

A UserError is raised in the following scenarios:

● If the execution leads to the formation of a loop in an object hierarchy, like assigning an object as its own parent.



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



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