Skip to content

Commit d88dbf1

Browse files
committed
[BUG] auditlog: Logging model read raises ReadOnlyTransaction error.
1 parent b80bca1 commit d88dbf1

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

auditlog/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22
from . import test_auditlog
33
from . import test_autovacuum
4+
from . import test_http
45
from . import test_multi_company

auditlog/tests/test_http.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
import logging
3+
4+
from odoo.tests.common import HttpCase, tagged
5+
6+
7+
@tagged("post_install", "-at_install")
8+
class TestAuditlogHttp(HttpCase):
9+
def test_read_only_cursor(self):
10+
self.authenticate("admin", "admin")
11+
rule = self.env["auditlog.rule"].create(
12+
{
13+
"name": "res.partner",
14+
"model_id": self.env.ref("base.model_res_partner").id,
15+
"log_read": True,
16+
"log_type": "full",
17+
"state": "subscribed",
18+
}
19+
)
20+
self.addCleanup(rule.unsubscribe)
21+
partner = self.env.ref("base.partner_demo")
22+
with self.assertNoLogs("odoo", level=logging.ERROR):
23+
self.make_jsonrpc_request(
24+
"/web/dataset/call_kw",
25+
params={
26+
"model": "res.partner",
27+
"method": "read",
28+
"args": [partner.ids],
29+
"kwargs": {},
30+
},
31+
headers={
32+
"Cookie": f"session_id={self.session.sid};",
33+
},
34+
)

0 commit comments

Comments
 (0)