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.

Parameters

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


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

Eg:


partner = self.env['res.partner'].create({
     'name':'Test Partner',
     'is_company':True
})
                             
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.

whatsapp
location

Calicut

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

location

Kochi

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

location

Bangalore

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

Send Us A Message