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.