Skip to content

Latest commit

 

History

History
219 lines (164 loc) · 6.36 KB

File metadata and controls

219 lines (164 loc) · 6.36 KB

SPP Audit Module Consolidation Summary

Overview

Successfully consolidated three audit modules into a single spp_audit module:

  • spp_audit_log (base module - core audit log and rule engine)
  • spp_audit_post (extension - parent-child hierarchy and message posting)
  • spp_audit_config (extension - create_rules() helper and default data)

Module Structure

Directory Layout

spp_audit/
├── __init__.py
├── __manifest__.py
├── models/
│   ├── __init__.py
│   ├── spp_audit_log.py         # Merged: base + post extensions
│   ├── spp_audit_rule.py        # Merged: base + post + config
│   └── group.py                 # Copied unchanged
├── views/
│   ├── spp_audit_log_views.xml  # Copied with updated XML IDs
│   └── spp_audit_rule_views.xml # Merged: base form + parent-child fields
├── security/
│   ├── privileges.xml           # Updated XML IDs
│   ├── audit_security.xml       # Updated XML IDs and references
│   └── ir.model.access.csv      # Updated group references
├── data/
│   └── audit_rule_data.xml      # Copied unchanged
├── tools/
│   ├── __init__.py
│   └── decorator.py             # Copied unchanged
├── tests/
│   ├── __init__.py
│   └── test_spp_audit_rule.py   # Copied unchanged
└── static/
    └── description/             # Copied unchanged

Key Merges

1. manifest.py

Combined dependencies from all three modules:

  • Base: base, mail, spp_registry_membership, spp_security
  • Post: (same as base)
  • Config: spp_programs, spp_service_points

Result: All dependencies unified in single manifest

2. models/spp_audit_log.py

Merged features:

  • Base model from spp_audit_log (lines 1-124)
  • Parent-child functionality from spp_audit_post:
    • parent_data_html field
    • parent_model_id field
    • parent_res_ids_str field
    • log_to field
    • create() method override for message posting
    • _parent_get_content() method
    • _compute_parent_data_html() method
    • _compute_log_to() method

3. models/spp_audit_rule.py

Merged features:

  • Base model from spp_audit_log (fields, methods, decorators)
  • Parent-child hierarchy from spp_audit_post:
    • _parent_name = "parent_id"
    • _parent_store = True
    • parent_id field
    • child_ids field
    • is_mail_thread field
    • field_id field
    • field_id_domain field
    • parent_path field
    • _check_model_id_field_id() constraint
    • _compute_field_id_domain() method
    • get_most_parent() method
    • Enhanced get_audit_log_vals() method
  • create_rules() helper method from spp_audit_config

4. views/spp_audit_rule_views.xml

Merged into single form:

  • Base form fields
  • Parent-child fields directly in form (not as inheritance):
    • parent_id field before name
    • field_id field after log options
    • child_ids notebook page with related rules list

5. security/

Updated XML IDs:

  • spp_audit_log.group_audit_log_managerspp_audit.group_manager
  • spp_audit_log.privilege_audit_log_managerspp_audit.privilege_audit_manager
  • Access rights now reference spp_audit.group_manager

Bug Fixes Applied

Field Naming Consistency

Fixed mismatch in create_rules() method where parameter names didn't match field names:

  • Changed "view_logs" to "is_view_logs"
  • Changed "log_create" to "is_log_create"
  • Changed "log_write" to "is_log_write"
  • Changed "log_unlink" to "is_log_unlink"

Files Copied Unchanged

  • models/group.py - Group member names computation
  • tools/decorator.py - Audit decorator for method patching
  • tests/test_spp_audit_rule.py - Unit tests
  • data/audit_rule_data.xml - Default audit rules
  • static/description/* - Icons and documentation

Key Changes from Original Modules

Module References

All references updated from:

  • spp_audit_log.*spp_audit.*
  • Menu IDs, group IDs, privilege IDs all use spp_audit prefix

Inheritance Patterns

  • spp_audit_post used _inherit = "spp.audit.log" → Now merged directly into base model
  • spp_audit_post used _inherit = "spp.audit.rule" → Now merged directly into base model
  • spp_audit_config used _inherit = "spp.audit.rule" → create_rules() merged into base model

View Architecture

  • Original: Base form + XML inheritance patch from spp_audit_post
  • Consolidated: Single unified form with all fields

Dependencies

Depends On:

  • base
  • mail
  • spp_registry_membership
  • spp_security
  • spp_programs
  • spp_service_points

Depended On By:

Any module that previously depended on spp_audit_log, spp_audit_post, or spp_audit_config will need to update their dependencies to spp_audit.

Migration Notes

For Dependent Modules:

  1. Update depends in manifest.py from spp_audit_log to spp_audit
  2. Update any XML ID references:
    • spp_audit_log.group_audit_log_managerspp_audit.group_manager
    • spp_audit_log.menu_rootspp_audit.menu_root
    • spp_audit_log.spp_audit_rule_formspp_audit.spp_audit_rule_form

For Database Migration:

No data migration should be needed as:

  • Model names remain unchanged (spp.audit.log, spp.audit.rule)
  • Field names remain unchanged
  • Only XML IDs and module names changed

Testing Recommendations

  1. Unit Tests: Run existing test_spp_audit_rule.py
  2. Integration Tests: Verify audit rules creation from data file
  3. Feature Tests:
    • Test basic audit logging (create/write/unlink)
    • Test parent-child audit relationships
    • Test message posting to parent records
    • Test create_rules() helper method
  4. UI Tests:
    • Verify audit rule form displays correctly
    • Verify related rules notebook on parent rules
    • Verify audit log display

Benefits of Consolidation

  1. Simplified Dependencies: One module instead of three
  2. Reduced Complexity: No inheritance chains to follow
  3. Better Performance: No additional module loading overhead
  4. Easier Maintenance: All related code in one place
  5. Clearer Architecture: Single source of truth for audit functionality

Verification

All files created successfully:

  • 20 files total (excluding pycache)
  • 3 Python model files
  • 2 view XML files
  • 3 security files
  • 1 data file
  • 2 tool files
  • 1 test file
  • 4 static resource files
  • 3 init.py files
  • 1 manifest.py file