Skip to content

Commit cfc9b26

Browse files
committed
Merge PR #1149 into 14.0
Signed-off-by tarteo
2 parents 783c6e6 + d957657 commit cfc9b26

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

website_require_login/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Contributors
6565
~~~~~~~~~~~~
6666

6767
* Ooops404 <https://ooops404.com>
68+
* `PyTech <https://www.pytech.it>`_:
69+
70+
* Simone Rubino <[email protected]>
6871

6972
Maintainers
7073
~~~~~~~~~~~

website_require_login/models/ir_http.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Copyright 2020 Advitus MB
2+
# Copyright 2025 Simone Rubino - PyTech
23
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
34
from pathlib import Path
45

5-
from psycopg2 import OperationalError
6+
from psycopg2 import InternalError
67

78
from odoo import models
89
from odoo.http import request
@@ -24,7 +25,9 @@ def _dispatch(cls):
2425
# raised and the cursor is currently closed
2526
try:
2627
user = website.user_id
27-
except OperationalError:
28+
except InternalError:
29+
# The real exception is InFailedSqlTransaction
30+
# it will be available in psycopg2>=2.8.*
2831
return res
2932
if request.uid == user.id:
3033
auth_paths = (
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
* Ooops404 <https://ooops404.com>
2+
* `PyTech <https://www.pytech.it>`_:
3+
4+
* Simone Rubino <[email protected]>

website_require_login/static/description/index.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
/*
1010
:Author: David Goodger ([email protected])
11-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1516
1617
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1718
customize this style sheet.
@@ -274,7 +275,7 @@
274275
margin-left: 2em ;
275276
margin-right: 2em }
276277

277-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
278279
pre.code, code { background-color: #eeeeee }
279280
pre.code .comment, code .comment { color: #5C6576 }
280281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
300301
span.pre {
301302
white-space: pre }
302303

303-
span.problematic {
304+
span.problematic, pre.problematic {
304305
color: red }
305306

306307
span.section-subtitle {
@@ -409,12 +410,18 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
409410
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
410411
<ul class="simple">
411412
<li>Ooops404 &lt;<a class="reference external" href="https://ooops404.com">https://ooops404.com</a>&gt;</li>
413+
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
414+
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
415+
</ul>
416+
</li>
412417
</ul>
413418
</div>
414419
<div class="section" id="maintainers">
415420
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
416421
<p>This module is maintained by the OCA.</p>
417-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
422+
<a class="reference external image-reference" href="https://odoo-community.org">
423+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
424+
</a>
418425
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
419426
mission is to support the collaborative development of Odoo features and
420427
promote its widespread use.</p>

website_require_login/tests/test_ir_http.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
# Copyright 2025 Simone Rubino - PyTech
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0).
3+
4+
import json
5+
16
from odoo.tests import HttpCase
7+
from odoo.tools import mute_logger
28

39

410
class TestIrHttp(HttpCase):
@@ -35,3 +41,32 @@ def test_dispatch_authorized(self):
3541
200,
3642
"Expected the response status code to be 200 which means no redirection",
3743
)
44+
45+
def test_dispatch_failed_transaction(self):
46+
"""If a transaction is failed, the exception is handled as usual."""
47+
cron = self.env["ir.cron"].create(
48+
{
49+
"name": "Test failed transaction",
50+
"code": "env.cr.execute('SELECT not_a_field FROM res_users')",
51+
"model_id": self.env.ref("base.model_res_partner").id,
52+
}
53+
)
54+
self.authenticate(user="admin", password="admin")
55+
with mute_logger("odoo.sql_db", "odoo.http"):
56+
response = self.url_open(
57+
"/web/dataset/call_button",
58+
headers={
59+
"Content-Type": "application/json",
60+
},
61+
data=json.dumps(
62+
{
63+
"params": {
64+
"model": cron._name,
65+
"method": "method_direct_trigger",
66+
"args": [cron.ids],
67+
"kwargs": {},
68+
},
69+
}
70+
),
71+
)
72+
self.assertEqual(response.status_code, 200)

0 commit comments

Comments
 (0)