This question has been flagged
2 Replies
3557 Views

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
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
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