Skip to Content

How to Log User Actions in Odoo with Audit Log

14 APRIL 2025

Logging User Actions in Odoo using the "Audit Log" Module

In various business contexts, it is essential to keep audit logs for actions impacting system data, including creation, reading, updating, and deletion (CRUD).

While Odoo's native version does not yet support this functionality, the OCA maintains a module that addresses these operations.

This review will explore the features provided by the "Audit Log" module.

The latest version available at the time of writing is 17.0.1.0.0. After installing the add-on, the relevant sub-menus can be accessed under the "Technical" menu.

There are five (5) sub-menus:

  • Rules
  • Logs
  • Log Lines
  • Use Sessions
  • HTTPS Requests

Only the "rules" sub-menu is customizable, while the other sub-menus are read-only list views containing various types of logs, each corresponding to their respective names.

To enable data logging, a rule must be created. Each rule is model-specific, meaning every model in the system requires its own log data. Besides selecting the model name, a rule includes the following additional fields:

  • Name: The rule's name, such as "Sales Order" for the sale.order model.
  • Type: Choose between "Full Log," which logs both the before and after states of data (including computed fields, though it may be slower due to complexity), and "Fast Log," which logs only the new values during create and write operations, making it faster.
  • Capture Record: If enabled, when a record is deleted, the full details will be logged. Otherwise, a simple log without detailed information will be created. This option is available only with "Full Log."
  • Action: Visible in debug mode, this field can be edited, but the "Subscribe" action will be overridden by the "View Logs" action created for the rule.
  • Users to Exclude: Specify multiple users to be excluded from the logs.
  • ​​Fields to Exclude:  List the fields to be excluded from the logs.
  • Log Reads: If enabled, a log will be created every time a user views the model's data. This is disabled by default.
  • Log Writes:  If enabled, a log will be created every time a user updates a record related to the model.
  • Log Deletes: If enabled, a log will be created when a user deletes a record related to the model.
  • Log Creates: If enabled, a log will be created when a user creates a new record related to the model.

The last three options are enabled by default when creating a new rule.

After creating the rule, the next step is to subscribe to it by clicking the "Subscribe" button.  This action initiates data logging based on the rule's configuration.

The rule can only be edited while in the "Draft" state. If changes are needed, the rule must be reverted to "Draft" using the "Unsubscribe" button.

From security perspective, the module has two groups:

  • Auditlog User
  • Auditlog Manager

The first one allows users to see the logs from the record using the action "View Log", which can be found in the record's action menu. The users with this group have only read access to the logs.

The “Auditlog Manager” group adds full access rights to the related audit log models, however, a user can have access to the Audit log menus only if they have the “Administration Settings” group.

The logs are by default kept in the system for 6 months, but it is possible to change that in the "Auto-vacuum audit logs” scheduled action that can be found in Settings > Technical > Automation > Scheduled Actions​.

The number 180 in the method model.autovacuum(180) represents the number of days logs are retained. Adjusting this number changes the retention period.

Additionally, a second parameter can be added to specify the number of logs deleted per run for each related model. This is useful when there are numerous logs to remove at once, as Odoo might fail to delete them all, leading to an accumulation of logs that can increase database size and slow down the system.

We recommend ensuring the scheduled action runs successfully and is configured to delete a limited number of logs per run at shorter intervals. It should be manually tested to confirm it works as expected once settings are applied.

The "Auto-vacuum audit logs" feature is not enabled by default and must be activated after installing the module.

This module is a valuable addition for systems requiring such functionality. It is regularly maintained by the Odoo Community Association (OCA), ensuring it is technically sound with proper quality assurance checks.

Blog Reference Click Here

Share this post
Archive
Odoo's Features and Improvements
07 APRIL 202