Ordered Tracking for
Custom fields
Any custom field in Odoo has the option
to have ordered tracking turned on in Studio. Steps to do this –
- Enable Debug
(developer) mode.
- Open Studio in the
form view.
- Click on the field in
question.
- On the left panel,
scroll down and click on “More”.
- You will find an
option called “Enable Ordered Tracking”.
Enter a number other
than 0 in the field. The number indicates the priority of the fields tracking.
If a field has a higher number, it has a higher priority and if multiple fields
are changed at the same time, the highest priority will show up on top.
Expected behavior for
Base fields
Base fields, on the other hand, will not allow you to
enable ordered tracking on them. If you follow the above-mentioned steps for
base fields you will notice that the ordered tracking field is read-only and
even if you try to bypass and make it editable, Odoo will give you an error
that says that base fields cannot be edited.
However, there is a workaround to make this possible
if clients need a way to track any changes made to base many2one fields. Keep in mind that this works only for many2one or relational fields and not char fields.
Workaround for enabling ordered tracking on base fields
Odoo does not prevent the user from enabling ordered
tracking on custom fields. We can use this to our advantage to track changes made
to base fields. The following steps will enable the user to create a custom field that is related to the base field, which can be tracked.
- Open studio in the form view.
- Drag and drop a new related field; and relate it to the
base field you want to track.
- You can name the related field whatever you want but
for the sake of tracking in the chatter, I would recommend naming it the same
as a base field but with a minor difference to differentiate between the two.
For example, you can call it “Country1” or “Country (tracking)” or something
along those lines. I recommend having the base field's name in it so that you
know what is being modified when it shows up on the chatter.
- Follow the steps above to enable ordered tracking on
the new related field.
- You can choose to make the new field hidden if you
want, to avoid any confusion and prevent cluttering the form view.
- Exit Studio.
You now have a hidden related field that will change when
the base field changes and because ordered tracking is enabled, it will be
displayed in the chatter. For example, if I change the Country field, the
chatter will display Country1 has been changed.