Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions auditlog/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=========
Audit Log
=========
Expand All @@ -17,7 +13,7 @@ Audit Log
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
Expand Down
1 change: 1 addition & 0 deletions auditlog/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"security/ir.model.access.csv",
"data/ir_cron.xml",
"views/auditlog_view.xml",
"views/auditlog_rule_actions.xml",
"views/http_session_view.xml",
"views/http_request_view.xml",
],
Expand Down
9 changes: 9 additions & 0 deletions auditlog/models/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,15 @@ def unsubscribe(self):
act_window.unlink()
return self.write({"state": "draft"})

def action_server_bulk_subscribe(self):
"""Bulk subscribe rules"""
self.filtered(lambda rule: rule.state != "subscribed").subscribe()
return True

def action_server_bulk_unsubscribe(self):
self.filtered(lambda rule: rule.state == "subscribed").unsubscribe()
return True

@api.model
def _update_vals_list(self, vals_list):
# Odoo supports empty recordset assignment (while it doesn't handle
Expand Down
30 changes: 12 additions & 18 deletions auditlog/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Audit Log</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="audit-log">
<h1 class="title">Audit Log</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="audit-log">
<h1>Audit Log</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0240f9c8def7a3e1f72b8168df9c7a528058198a4abada52388cd412a8babf62
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/17.0/auditlog"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-auditlog"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/17.0/auditlog"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-auditlog"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows the administrator to log user operations performed on
data models such as <tt class="docutils literal">create</tt>, <tt class="docutils literal">read</tt>, <tt class="docutils literal">write</tt> and <tt class="docutils literal">delete</tt>.</p>
<p><strong>Table of contents</strong></p>
Expand All @@ -393,7 +388,7 @@ <h1>Audit Log</h1>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>Go to Settings / Technical / Audit / Rules to subscribe rules. A rule
defines which operations to log for a given data model.</p>
<p><img alt="image" src="https://raw.githubusercontent.com/OCA/server-tools/17.0/auditlog/static/description/rule.png" /></p>
Expand All @@ -417,7 +412,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
right to configure the auditlog configuration rules.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<blockquote>
<ul class="simple">
<li>log only operations triggered by some users (currently it logs all
Expand All @@ -428,23 +423,23 @@ <h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
</blockquote>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20auditlog%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>ABF OSIELL</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Sebastien Alix &lt;<a class="reference external" href="mailto:sebastien.alix&#64;camptocamp.com">sebastien.alix&#64;camptocamp.com</a>&gt;</li>
<li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li>
Expand All @@ -461,14 +456,14 @@ <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
</ul>
</div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#toc-entry-7">Other credits</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<ul class="simple">
<li>Icon: built with different icons from the <a class="reference external" href="https://en.wikipedia.org/wiki/Oxygen_Project">Oxygen
theme</a> (LGPL)</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -481,6 +476,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
75 changes: 75 additions & 0 deletions auditlog/tests/test_auditlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,78 @@ def test_01_AuditlogFast_field_exclude_write_log(self):
]
)
)


class AuditLogRuleBulkActions(AuditLogRuleCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
country_model = cls.env.ref("base.model_res_country")
state_model = cls.env.ref("base.model_res_country_state")

existing_rules = cls.env["auditlog.rule"].search(
[("model_id", "in", (country_model.id, state_model.id))]
)
existing_rules.action_server_bulk_unsubscribe()
existing_rules.unlink()

cls.rule_country = cls.create_rule(
{
"name": "Country bulk rule",
"model_id": country_model.id,
"log_read": False,
"log_create": True,
"log_write": True,
"log_unlink": True,
"log_type": "fast",
}
)
cls.rule_state = cls.create_rule(
{
"name": "State bulk rule",
"model_id": state_model.id,
"log_read": False,
"log_create": True,
"log_write": True,
"log_unlink": True,
"log_type": "fast",
}
)
cls.rules = cls.rule_country | cls.rule_state

@classmethod
def tearDownClass(cls):
if cls.rules:
cls.rules.action_server_bulk_unsubscribe()
cls.rules.unlink()
super().tearDownClass()

def test_01_bulk_subscribe(self):
self.rules.action_server_bulk_unsubscribe()

action_result = self.rules.action_server_bulk_subscribe()

self.assertTrue(action_result)
self.rules.invalidate_recordset()
self.assertTrue(all(rule.state == "subscribed" for rule in self.rules))
for rule in self.rules:
self.assertTrue(rule.action_id)
self.assertEqual(rule.action_id.binding_model_id, rule.model_id)

def test_02_bulk_unsubscribe(self):
self.rules.action_server_bulk_unsubscribe()
self.rules.action_server_bulk_subscribe()
self.rules.invalidate_recordset()
action_ids = self.rules.mapped("action_id.id")
self.assertTrue(action_ids)

action_result = self.rules.action_server_bulk_unsubscribe()

self.assertTrue(action_result)
self.rules.invalidate_recordset()
self.assertTrue(all(rule.state == "draft" for rule in self.rules))
self.assertFalse(any(self.rules.mapped("action_id")))
remaining_actions = self.env["ir.actions.act_window"].search(
[("id", "in", action_ids)]
)
self.assertFalse(remaining_actions)
20 changes: 20 additions & 0 deletions auditlog/views/auditlog_rule_actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="action_auditlog_rule_subscribe" model="ir.actions.server">
<field name="name">Subscribe Rules</field>
<field name="model_id" ref="model_auditlog_rule" />
<field name="binding_model_id" ref="model_auditlog_rule" />
<field name="binding_type">action</field>
<field name="state">code</field>
<field name="code">action = records.action_server_bulk_subscribe()</field>
</record>

<record id="action_auditlog_rule_unsubscribe" model="ir.actions.server">
<field name="name">Unsubscribe Rules</field>
<field name="model_id" ref="model_auditlog_rule" />
<field name="binding_model_id" ref="model_auditlog_rule" />
<field name="binding_type">action</field>
<field name="state">code</field>
<field name="code">action = records.action_server_bulk_unsubscribe()</field>
</record>
</odoo>