Odoo Help


[8.0] Computed field with bulk write

Emanuel Cino
on 7/1/15, 9:08 AM 860 views

In official documentation, we have the following example for computed fields :

total = fields.Float(compute='_compute_total') 

@api.depends('value', 'tax')
def _compute_total(self):
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() ?


Anil R. Kesariya

--Anil R. Kesariya--
| 7 6 8
Rajkot, India
--Anil R. Kesariya--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.

Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66

Anil R. Kesariya
On 7/1/15, 9:23 AM

Hi Emanuel,

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.



Sorry, my question was not very clear. I wanted to know what should we do specifically for computed fields. Can we decorate the compute functions used in fields with @api.multi ?

Emanuel Cino
on 7/2/15, 1:50 AM

@Emanuel cino, Yes when you decorate your computational field with api.multi than it will auto trigger the that methods when the records will be loaded or any changes going to happen in any of record in the same model.

Anil R. Kesariya
on 8/17/15, 9:49 PM

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/1/15, 9:08 AM
Seen: 860 times
Last updated: 7/2/15, 1:49 AM