Skip to content

Commit edf9494

Browse files
committed
[MIG] : Migration to 18.0
1 parent 39c2fb7 commit edf9494

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
lines changed

rest_log/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "REST Log",
77
"summary": "Track REST API calls into DB",
8-
"version": "16.0.1.0.2",
8+
"version": "18.0.1.0.0",
99
"development_status": "Beta",
1010
"website": "https://github.com/OCA/rest-framework",
1111
"author": "Camptocamp, ACSONE, Odoo Community Association (OCA)",

rest_log/components/service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
from werkzeug.urls import url_encode, url_join
1111

12-
from odoo import exceptions, registry
12+
from odoo import exceptions
1313
from odoo.http import Response, request
14+
from odoo.modules.registry import Registry
1415

1516
from odoo.addons.base_rest.http import JSONEncoder
1617
from odoo.addons.component.core import AbstractComponent
@@ -98,7 +99,7 @@ def _dispatch_exception(
9899
try:
99100
exc_msg = self._get_exception_message(orig_exception)
100101
tb = traceback.format_exc()
101-
with registry(self.env.cr.dbname).cursor() as cr:
102+
with Registry(self.env.cr.dbname).cursor() as cr:
102103
log_entry = self._log_call_in_db(
103104
self.env(cr=cr),
104105
request,
@@ -124,7 +125,7 @@ def _get_log_entry_url(self, entry):
124125
"model": entry._name,
125126
"id": entry.id,
126127
}
127-
url = "/web?#%s" % url_encode(url_params)
128+
url = f"/web?#{url_encode(url_params)}"
128129
return url_join(base_url, url)
129130

130131
@property

rest_log/data/ir_cron_data.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
<odoo noupdate="1">
33
<record id="ir_cron_autovacuum_rest_log" model="ir.cron">
44
<field name="name">Auto-vacuum REST Logs</field>
5-
<field ref="model_rest_log" name="model_id" />
6-
<field eval="True" name="active" />
5+
<field name="model_id" ref="model_rest_log" />
6+
<field name="active" eval="True" />
77
<field name="user_id" ref="base.user_root" />
88
<field name="interval_number">1</field>
99
<field name="interval_type">days</field>
10-
<field name="numbercall">-1</field>
11-
<field eval="False" name="doall" />
1210
<field name="state">code</field>
1311
<field name="code">model.autovacuum()</field>
1412
</record>

rest_log/hooks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
_logger = logging.getLogger(__name__)
66

77

8-
def pre_init_hook(cr):
8+
def pre_init_hook(env):
99
"""On first install copy recods from shopfloor_log table if available."""
10-
cr.execute("SELECT 1 FROM pg_class WHERE relname = 'rest_log'")
11-
if cr.fetchone():
10+
env.cr.execute("SELECT 1 FROM pg_class WHERE relname = 'rest_log'")
11+
if env.cr.fetchone():
1212
# rest_log was already installed
1313
return
1414
_logger.info("Copy shopfloor.log records to rest.log")
15-
cr.execute(
15+
env.cr.execute(
1616
"""
1717
INSERT INTO rest_log (
1818
request_url,
@@ -49,4 +49,4 @@ def pre_init_hook(cr):
4949
"""
5050
)
5151
_logger.info("Delete legacy records in shopfloor_log")
52-
cr.execute("""DELETE FROM shopfloor_log""")
52+
env.cr.execute("""DELETE FROM shopfloor_log""")

rest_log/views/rest_log_views.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<field name="name">rest.log tree</field>
55
<field name="model">rest.log</field>
66
<field name="arch" type="xml">
7-
<tree decoration-danger="state == 'failed'">
7+
<list decoration-danger="state == 'failed'">
88
<field name="collection" optional="hide" />
99
<field name="collection_id" optional="hide" />
1010
<field name="create_uid" />
@@ -15,29 +15,28 @@
1515
<field name="exception_name" />
1616
<field name="exception_message" />
1717
<field name="severity" />
18-
</tree>
18+
</list>
1919
</field>
2020
</record>
2121
<record id="rest_log_form_view" model="ir.ui.view">
2222
<field name="name">rest.log form</field>
2323
<field name="model">rest.log</field>
2424
<field name="arch" type="xml">
2525
<form>
26-
<field name="collection_id" invisible="1" />
2726
<header>
2827
<field name="state" widget="statusbar" />
2928
</header>
3029
<sheet>
3130
<div
3231
class="oe_button_box"
3332
name="button_box"
34-
attrs="{'invisible': ['|', ('id','=',False), ('collection_id', '=', False)]}"
33+
invisible="['|', ('id','=',False), ('collection_id', '=', False)]"
3534
>
3635
<button
3736
type="object"
3837
name="action_view_collection"
3938
icon="fa-eye"
40-
attrs="{'invisible': [('collection_id', '=', False)]}"
39+
invisible="[('collection_id', '=', False)]"
4140
>
4241
View collection
4342
</button>
@@ -60,7 +59,7 @@
6059
<group
6160
string="Result"
6261
name="result"
63-
attrs="{'invisible': [('state', '!=', 'success')]}"
62+
invisible="[('state', '!=', 'success')]"
6463
>
6564
<group>
6665
<field name="result" nolabel="1" widget="ace" colspan="2" />
@@ -69,7 +68,7 @@
6968
<group
7069
string="Error"
7170
name="error"
72-
attrs="{'invisible': [('state', '!=', 'failed')]}"
71+
invisible="[('state', '!=', 'failed')]"
7372
>
7473
<group colspan="2">
7574
<field name="exception_name" />

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
httpx
2+
odoo-addon-base-rest @ git+https://github.com/OCA/rest-framework@refs/pull/506/head#subdirectory=base_rest

0 commit comments

Comments
 (0)