Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
In official documentation, we have the following example for computed fields :
total = fields.Float(compute='_compute_total')
for record in self:
record.total = record.value + record.value * record.tax
On the guidelines, we can read :
Be aware that this assignation will trigger a write into the database. If you need to do bulk change or must be careful about performance, you should do classic call to write
My question is how can we do the bulk change ? Is it valid to add the decorator @api.multi over the compute function and do something like self.write() ?
Yes by using decorator @api.multi you can write bulk record of same model.
If you are overriding write metho than you have to define decorator
This is the standard convention we always use multi for write because if write method is already overriden some where in custom module it will create singlton error if you not follow the multi api.
Suggestion is to always use api.multi when write come to picture.
Hope this will help.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 7/1/15, 9:08 AM|
|Seen: 607 times|
|Last updated: 7/2/15, 1:49 AM|