ActivityLog
Activity log entry DocType.
Stores an immutable audit record of a user action on a document.
Once created, activity logs should never be modified or deleted.
Attributes:
user_id: ID of the user who performed the action
action: Type of action ("create", "read", "update", "delete")
doctype: Name of the affected DocType
document_id: ID of the affected document
timestamp: When the action occurred (auto-set)
changes: Field changes for updates (old/new values)
metadata: Additional context (request_id, ip, user_agent)
Example:
log = ActivityLog(
user_id="user-001",
action="create",
doctype="Todo",
document_id="TODO-001",
)
Source: activity_log.py
Fields
| Field | Type | Required | Description | Validators |
|---|---|---|---|---|
| user_id | str | ✓ | ID of the user who performed the action | minLen: 1 |
| action | str | ✓ | Type of action: create, read, update, delete | pattern: `^(create |
| doctype | str | ✓ | Name of the affected DocType | minLen: 1 |
| document_id | str | ✓ | ID of the affected document | minLen: 1 |
| timestamp | datetime | When the action occurred (UTC) | - | |
| changes | dict[str, Any] | None | Field changes for updates: {field: {old: x, new: y}} | |
| metadata | dict[str, Any] | None | Additional context: request_id, ip, user_agent, etc. |
Permissions
| Role | Create | Delete | Read | Write |
|---|---|---|---|---|
| All | ✓ | |||
| System Manager | ✓ | ✓ |
Configuration
| Setting | Value |
|---|---|
| Submittable | False |
| Track Changes | True |
Controller
Controller hooks are implemented in *_controller.py files.
Available lifecycle hooks:
validate()- Called before save, raise exceptions for validation errorsbefore_insert()- Called before inserting a new documentafter_insert()- Called after successfully insertingbefore_save()- Called before saving (insert or update)after_save()- Called after savingbefore_delete()- Called before deletingafter_delete()- Called after deleting