The common ORM methods in Odoo are listed below :
The create() method is used to create new records for the model. It accepts the set of dictionary values.
When you create a new record in odoo, when saved that record the base create is called.
The write() method is used to update your records in the model. It accepts the set of dictionary values and updates the record with those values.
When you click on the Edit button in odoo default at that time the base write() method is called.
The copy() method is used to duplicate the record in your model. This is only a default argument.
copy = True
If you don’t want to duplicate your data then you have to write copy=False in your argument.
The search() method is used for searching the record on that model. It’s used in multiple ways ; just like search by id, search all the records of that model.
We can also give the limit by searching the element .
For Example: If you want to search all the record of that model then,
If you want to search particular record then ,
self.search([ (‘argument’),limit=2 ])
5. search_count ()
This method returns the number of records matching which we gave in the search_count() domain. It accepts the domain as an argument .
Syntax: model.search_count([ domain passed here ])
The browse() method is used to return a set of records for the IDs passed as the parameter in the model. The browse method accepts a set of IDs and returns the recordsets corresponding to those IDs. It takes a database id or a list of ids and returns a recordset.
Syntax: model.browse([pass here ids])
The unlink() method is used to delete or remove the records or record set from the model. This method does not take any arguments, it removes the current records which are active.
Syntax : model.unlink( no arguments )
This method checks whether the record set holds a single record or not. Otherwise raise an exception. It also check that the current record is singleton.
This function makes sure that we get a single record not multiple records.