Help

4

what is difference between def write and def _write in odoo v12 community .

Avatar
bhavik vyas

I can find there are 3 instances where in code of odoo v 12 community 
instead of overriding write orm method _write is overriden .

1) account module -> account_invoice.py

2) base_automation module -> base_automation.py

3) sale module -> sale.py

so my question is what is difference between def write and def _write

and when to use def _write instead def write ??

Regards.



Avatar
Discard
2 Answers
4
Avatar
Nikul Chaudhary
Best Answer

Hello

  1. def write:
     Updates all records values with the provided values.

  2. def _write:
    low-level implementation of write and normally it gets called from write.
    this method check constraints on records.

Avatar
Discard
0
Avatar
Hiren Patel
Best Answer

_write : when compute field changed its value it called _write method.

write: Update records with given ids with the given field values

Avatar
Discard