Skip to content

Commit 26e94fc

Browse files
acsonefhoAnizR
authored andcommitted
[IMP] queue_job: avoid deprecation warning about datetime utcnow()
datetime.datetime.utcnow() is now deprecated and should be replaced by datetime.datetime.now() (optional TZ parameter). As the original _odoo_now() doesn't contain the Timezone, the parameter datetime.UTC is not added into this improvement
1 parent f832ffd commit 26e94fc

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

queue_job/jobrunner/runner.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
of running Odoo is obviously not for production purposes.
140140
"""
141141

142-
import datetime
143142
import logging
144143
import os
145144
import selectors
@@ -181,15 +180,10 @@ def _channels():
181180
)
182181

183182

184-
def _datetime_to_epoch(dt):
183+
def _odoo_now():
185184
# important: this must return the same as postgresql
186185
# EXTRACT(EPOCH FROM TIMESTAMP dt)
187-
return (dt - datetime.datetime(1970, 1, 1)).total_seconds()
188-
189-
190-
def _odoo_now():
191-
dt = datetime.datetime.utcnow()
192-
return _datetime_to_epoch(dt)
186+
return time.time()
193187

194188

195189
def _connection_info_for(db_name):

0 commit comments

Comments
 (0)