From c6a30604b823ca93a4f6cd6e97b3ab052be230d5 Mon Sep 17 00:00:00 2001 From: sebalix Date: Tue, 9 Apr 2019 13:10:10 +0200 Subject: [PATCH] [IMP] auditlog: set all fields readonly when the rule is enabled --- auditlog/models/rule.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/auditlog/models/rule.py b/auditlog/models/rule.py index 2dd073978..c4d061cd4 100644 --- a/auditlog/models/rule.py +++ b/auditlog/models/rule.py @@ -44,32 +44,40 @@ class AuditlogRule(models.Model): _name = 'auditlog.rule' _description = "Auditlog - Rule" - name = fields.Char("Name", size=32, required=True) + name = fields.Char( + "Name", required=True, + states={'subscribed': [('readonly', True)]}) model_id = fields.Many2one( 'ir.model', "Model", required=True, - help="Select model for which you want to generate log.") + help="Select model for which you want to generate log.", + states={'subscribed': [('readonly', True)]}) user_ids = fields.Many2many( 'res.users', 'audittail_rules_users', 'user_id', 'rule_id', string="Users", - help="if User is not added then it will applicable for all users") + help="if User is not added then it will applicable for all users", + states={'subscribed': [('readonly', True)]}) log_read = fields.Boolean( "Log Reads", help=("Select this if you want to keep track of read/open on any " - "record of the model of this rule")) + "record of the model of this rule"), + states={'subscribed': [('readonly', True)]}) log_write = fields.Boolean( "Log Writes", default=True, help=("Select this if you want to keep track of modification on any " - "record of the model of this rule")) + "record of the model of this rule"), + states={'subscribed': [('readonly', True)]}) log_unlink = fields.Boolean( "Log Deletes", default=True, help=("Select this if you want to keep track of deletion on any " - "record of the model of this rule")) + "record of the model of this rule"), + states={'subscribed': [('readonly', True)]}) log_create = fields.Boolean( "Log Creates", default=True, help=("Select this if you want to keep track of creation on any " - "record of the model of this rule")) + "record of the model of this rule"), + states={'subscribed': [('readonly', True)]}) log_type = fields.Selection( [('full', "Full log"), ('fast', "Fast log"), @@ -79,7 +87,8 @@ class AuditlogRule(models.Model): "the operation (log more info like computed fields which were " "updated, but it is slower)\n" "Fast log: only log the changes made through the create and " - "write operations (less information, but it is faster)")) + "write operations (less information, but it is faster)"), + states={'subscribed': [('readonly', True)]}) # log_action = fields.Boolean( # "Log Action", # help=("Select this if you want to keep track of actions on the " @@ -92,7 +101,8 @@ class AuditlogRule(models.Model): [('draft', "Draft"), ('subscribed', "Subscribed")], string="State", required=True, default='draft') action_id = fields.Many2one( - 'ir.actions.act_window', string="Action") + 'ir.actions.act_window', string="Action", + states={'subscribed': [('readonly', True)]}) _sql_constraints = [ ('model_uniq', 'unique(model_id)',