From 6514df80920641594bb519c92a667654ca4995e0 Mon Sep 17 00:00:00 2001 From: red Date: Wed, 3 Jan 2024 11:27:04 +0800 Subject: [PATCH] update fields to log of the default audit rules --- spp_audit_config/data/audit_rule_data.xml | 32 ++++++++++++++++++----- spp_audit_config/models/spp_audit_rule.py | 7 ++--- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/spp_audit_config/data/audit_rule_data.xml b/spp_audit_config/data/audit_rule_data.xml index 0c261b57..93f1193a 100644 --- a/spp_audit_config/data/audit_rule_data.xml +++ b/spp_audit_config/data/audit_rule_data.xml @@ -4,7 +4,7 @@ Program Rule g2p.program - + @@ -18,21 +18,30 @@ Registry Rule res.partner - + Service Point Rule spp.service.point - + Default Eligibility Manager Rule g2p.program_membership.manager.default - + Program Rule program_id @@ -62,7 +71,10 @@ Program Manager Rule g2p.program.manager.default - + Program Rule program_id @@ -72,7 +84,10 @@ Cycle Manager Rule g2p.cycle.manager.default - + Program Rule program_id @@ -112,7 +127,10 @@ Basket Entitlement Manager Rule g2p.program.entitlement.manager.basket - + Program Rule program_id diff --git a/spp_audit_config/models/spp_audit_rule.py b/spp_audit_config/models/spp_audit_rule.py index d3b3dcca..71852aa8 100644 --- a/spp_audit_config/models/spp_audit_rule.py +++ b/spp_audit_config/models/spp_audit_rule.py @@ -19,8 +19,6 @@ def create_rules( **kwargs ): rule = self.env["spp.audit.rule"].search([("name", "=", rule_name)], limit=1) - if rule: - return model_id = self.env["ir.model"].search([("model", "=", model)]) if model_id: @@ -62,6 +60,9 @@ def create_rules( } ) - self.env["spp.audit.rule"].create(vals) + if rule: + rule.write(vals) + else: + self.env["spp.audit.rule"].create(vals) return