Skip to content

Commit 98a9bef

Browse files
SilvioC2CJordiMForgeFlow
authored andcommitted
[MIG] endpoint: Migration to 17.0
1 parent d15427a commit 98a9bef

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

endpoint/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Endpoint",
66
"summary": """Provide custom endpoint machinery.""",
7-
"version": "16.0.1.3.0",
7+
"version": "17.0.1.0.0",
88
"license": "LGPL-3",
99
"development_status": "Beta",
1010
"author": "Camptocamp,Odoo Community Association (OCA)",

endpoint/models/endpoint_mixin.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,30 @@ def _code_snippet_log_func(self, message, level="info"):
116116
cr.execute(
117117
"""
118118
INSERT INTO ir_logging
119-
(create_date, create_uid, type, dbname, name, level, message, path, line, func)
120-
VALUES (NOW() at time zone 'UTC', %s, %s, %s, %s, %s, %s, %s, %s, %s)
119+
(
120+
create_date,
121+
create_uid,
122+
type,
123+
dbname,
124+
name,
125+
level,
126+
message,
127+
path,
128+
line,
129+
func
130+
)
131+
VALUES (
132+
NOW() at time zone 'UTC',
133+
%s,
134+
%s,
135+
%s,
136+
%s,
137+
%s,
138+
%s,
139+
%s,
140+
%s,
141+
%s
142+
)
121143
""",
122144
(
123145
self.env.uid,
@@ -156,8 +178,9 @@ def _code_snippet_valued(self):
156178
)
157179

158180
def _default_endpoint_options_handler(self):
181+
kdp = "odoo.addons.endpoint.controllers.main.EndpointController"
159182
return {
160-
"klass_dotted_path": "odoo.addons.endpoint.controllers.main.EndpointController",
183+
"klass_dotted_path": kdp,
161184
"method_name": "auto_endpoint",
162185
"default_pargs": (self._name, self.route),
163186
}
@@ -206,10 +229,9 @@ def _find_endpoint_domain(self, endpoint_route):
206229
return [("route", "=", endpoint_route)]
207230

208231
def copy_data(self, default=None):
209-
result = super().copy_data(default=default)
210-
# `route` cannot be copied as it must me unique.
232+
# OVERRIDE: ``route`` cannot be copied as it must me unique.
211233
# Yet, we want to be able to duplicate a record from the UI.
212-
for rec, data in zip(self, result):
213-
if not data.get("route"):
214-
data["route"] = f"{rec.route}/COPY_FIXME"
215-
return result
234+
self.ensure_one()
235+
default = dict(default or {})
236+
default.setdefault("route", f"{self.route}/COPY_FIXME")
237+
return super().copy_data(default=default)

endpoint/tests/test_endpoint_controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def setUpClass(cls):
1919
cls.env["endpoint.endpoint"].search([])._handle_registry_sync()
2020

2121
def tearDown(self):
22-
self.env["ir.http"]._clear_routing_map()
22+
# Clear cache for method ``ir.http.routing_map()``
23+
self.env.registry.clear_cache("routing")
2324
super().tearDown()
2425

2526
def test_call1(self):

endpoint/views/endpoint_view.xml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
name="web_ribbon"
1717
title="Archived"
1818
bg_color="bg-warning"
19-
attrs="{'invisible': [('active', '=', True)]}"
19+
invisible="active"
2020
/>
2121
<sheet>
2222
<div
2323
class="alert alert-warning"
2424
role="alert"
25-
attrs="{'invisible': ['|', ('registry_sync', '=', True), ('id', '=', False)]}"
25+
invisible="registry_sync or not id"
2626
>
2727
<p>
2828
Registry out of sync. Likely the record has been modified but not sync'ed with the routing registry.
@@ -53,7 +53,7 @@
5353
<field name="exec_mode" />
5454
<field
5555
name="exec_as_user_id"
56-
attrs="{'required': [('auth_type', '=', 'public')]}"
56+
required="auth_type == 'public'"
5757
/>
5858
</group>
5959
<group name="auth" string="Auth">
@@ -65,23 +65,19 @@
6565
<field name="request_method" />
6666
<field
6767
name="request_content_type"
68-
attrs="{'required': [('request_method', 'in', ('POST', 'PUT'))],
69-
'invisible': [('request_method', 'not in', ('POST', 'PUT'))]}"
68+
required="request_method in ('POST', 'PUT')"
69+
invisible="request_method not in ('POST', 'PUT')"
7070
/>
7171
</group>
7272
</group>
7373
</page>
74-
<page
75-
name="code"
76-
string="Code"
77-
attrs="{'invisible': [('exec_mode', '!=', 'code')]}"
78-
>
74+
<page name="code" string="Code" invisible="exec_mode != 'code'">
7975
<field name="code_snippet" widget="ace" />
8076
</page>
8177
<page
8278
name="code_help"
8379
string="Code Help"
84-
attrs="{'invisible': [('exec_mode', '!=', 'code')]}"
80+
invisible="exec_mode != 'code'"
8581
>
8682
<field name="code_snippet_docs" />
8783
</page>

0 commit comments

Comments
 (0)