Creating or writing multiple records
If you are new to Odoo development, you might execute multiple queries to write or create multiple records. In this recipe, we will look at how to create and write records in batches.
How to do it...
Creating multiple records and writing on multiple records work differently under the hood. Let’s see each of these records one by one.
Creating multiple records
Odoo supports creating records in batches. If you are creating a single record, simply pass a dictionary with the field values. To create records in a batch, you just need to pass a list of these dictionaries instead of a single dictionary. The following example creates three room records in a single create
call:
vals = [{ Â Â Â Â 'name': "Room A-101", Â Â Â Â 'room_no': 101, Â Â Â Â 'floor_no': 1, Â Â Â Â 'student_per_room': 2, }, { Â Â Â Â ...