In this article you will learn how and why we use copy function in Odoo. Sometime we need to create duplicate records with some new id (object id or Foreign Key). To achieve this we use copy function provided by Odoo.
Benefit of using copy function in Odoo
By using copy function we don't need to create values of dictionary. For example a model has 30+ fields, and we want to create a new record using same records using python code.
Read More: How to Duplicate Records using Copy and Copy Data Function in Odoo15
To do that we have to create values of dictionary that contains 30+ key value pairs. To avoid this we use copy function provided by Odoo.
- primary_key_id (id of the record for which you want to copy field value to create new record)
- .copy function will contains dictionary of key value pair for all the 30 fields
- some_field (If you want to change some record value than pass value here)
0 Comments