Audit log¶
The Audit Log module (auditlog) records the operations performed by the users on the data models
selected by the administrator: creations, modifications, deletions, and, optionally, consultations.
For every logged operation, the module keeps the user, the date, the record, and the old and new
value of each modified field.
Unlike the tracking messages of the chatter, the audit log works on any model (including the ones without a chatter), covers all the fields, and can only be consulted by authorized users.
Note
The menus of the module are located under . They are displayed in developer mode to the users with the Administration: Settings access right.
Audit rules¶
A rule defines which operations are logged for a model. There can only be one rule per model.
Go to , click New, and fill in the fields:
Name: the name of the rule;
Model: the model to audit (e.g., Contact or Product);
Type:
Full log: the data of the record is compared before and after the operation. The log also contains the computed fields that changed as a consequence of the operation, but the operation is slower;
Fast log: only the values sent by the create and write operations are logged. The log contains less information, but the impact on performance is lower;
Log Reads, Log Writes, Log Deletes, Log Creates: the operations to log. All of them are enabled by default, except Log Reads;
Capture Record: displayed for a Full log rule with Log Deletes enabled; tick it to keep the field values of the deleted records in the log;
Users to Exclude: the users whose operations are not logged (e.g., a technical user running an integration);
Fields to Exclude: the fields of the model that are left out of the log.
Then, click Subscribe to start logging. The rule moves to the Subscribed status, and its fields become read-only. To modify or stop a rule, click Unsubscribe first; the logs already recorded are kept.
Warning
Logging has a cost: every logged operation creates additional records. Avoid Log Reads and Full log rules on models with heavy traffic (e.g., journal items, stock moves, or messages), and enable the automatic clean-up.
- menu
- Settings ‣ Technical ‣ Audit ‣ Rules ‣ New (developer mode)
- shows
- An audit rule form in the Draft status with the Subscribe button, the model "Contact", the type "Full log", the excluded users and fields, and the four Log checkboxes (Reads unticked, the others ticked).
- highlight
- The "Subscribe" button and the four "Log ..." checkboxes (red frames).
- data
- Rule "Contacts audit"; Users to Exclude "OdooBot"; Fields to Exclude "Last Updated on".
- module
- auditlog
- notes
- English UI, light theme, 1440px width, developer mode enabled.
Consult the logs¶
From a record¶
As soon as a rule is subscribed, a View logs entry is added to the Action menu of the audited model. Open a record (or select it in the list view), and click to display the operations logged for that record.
This entry is the only access to the logs for the users who belong to the Auditlog User group without being administrators.
Access rights¶
The module adds the Auditlog Rights category to the access rights of the users, with two levels:
Auditlog User: read-only access to the logs, through the View logs action of the audited records;
Auditlog Manager: in addition, can create, modify, subscribe, and delete rules, and delete logs. Users with the Administration: Settings access right are automatically managers.
Automatic clean-up of old logs¶
The Auto-vacuum audit logs scheduled action deletes the logs, the log lines, the user sessions, and the HTTP requests older than 180 days. It is disabled by default.
To enable it, go to ,
open Auto-vacuum audit logs, and turn on the Active toggle. To keep the logs
for a different period, change the number of days in the code of the action, e.g.,
model.autovacuum(365) for one year.