How it works...

By adding the track_visibility attribute on the field, you can enable logging for that field. It has two possible values—onchange and always. When you set the track_visibility="onchage" attribute, Odoo will add a log that changes in the chatter whenever you update the field value. When you set the track_visibility="always" attribute, Odoo will always display the field value in the log even if its value is not changed. This is used to make the log more informative. Of course, fields with the track_visibility="always" attribute will add logs when the value of the field is changed.

In our recipe, we added track_visibility='always' on the state field and track_visibility='onchange' on the rent_date and return_date fields. This means Odoo will log the changes when you update the values of the rent_date, return_date, or state fields. But because the state field is set to track_visibility='always', its value will be logged even if its value is not changed. Take a look at the screenshot in the How to do it section; we have only changed the rent_date field, and set the log to display State: Ongoing.

Note that the track_visibility feature only works if your model inherits the mail.thread model because the code-related chatter and logs are part of the mail.thread model.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset