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

self.env['model.name'].create({
   'field_1': value_1,
   'field_2': value_2,
}) 

E.g., creating a customer:

self.env['res.partner'].create({
   'name': 'John Doe',
   'email': 'john@example.com',
   'phone': '1234567890',
})
  • It will raise an AccessError
    If the user lacks the necessary permissions to create the requested object.
    An AccessError is raised if the user attempts to bypass access control rules when creating the requested object.
  • It will raise ValidationError
    If a user inputs an invalid value into a non-selection field, a ValidationError will be raised.
  • It will raise UserError
    A UserError is raised when an operation would create a loop in an object hierarchy—for example, assigning an object as its own parent.
whatsapp_icon
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