22 lines
851 B
Python
Executable File
22 lines
851 B
Python
Executable File
from odoo import models, fields, api
|
|
|
|
class SOS_Audit_Log(models.Model):
|
|
_name = 'sos_audit_log'
|
|
_description = 'Audit Log'
|
|
_order = 'id desc'
|
|
|
|
name = fields.Selection([('Request','Request'),('Creation','Creation'),('Deletion','Deletion'),('Updation','Updation'),('Approval','Approval')],string='Action')
|
|
user_id = fields.Many2one('res.users', string='Done By', readonly=True)
|
|
date_time = fields.Datetime(string='Date Time', default=fields.Datetime.now, readonly=True)
|
|
description = fields.Html(string='Event')
|
|
|
|
@api.model
|
|
def create_log(self, action, description):
|
|
"""Utility method to log events directly from the audit log model."""
|
|
log_vals = {
|
|
'name': action,
|
|
'user_id': self.env.user.id,
|
|
'description': description,
|
|
}
|
|
self.create(log_vals)
|