Skip to content
Snippets Groups Projects
Commit e9bd1cb3 authored by OCA Git Bot's avatar OCA Git Bot
Browse files

Merge remote-tracking branch 'odoo/14.0' into 14.0

parents 11f66682 7bedae38
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
import datetime
import json
import logging
import os
import random
import select
import threading
......@@ -12,11 +13,16 @@ from odoo import api, fields, models, SUPERUSER_ID
from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.tools import date_utils
from psycopg2 import sql
_logger = logging.getLogger(__name__)
# longpolling timeout connection
TIMEOUT = 50
# custom function to call instead of NOTIFY postgresql command (opt-in)
ODOO_NOTIFY_FUNCTION = os.environ.get('ODOO_NOTIFY_FUNCTION')
#----------------------------------------------------------
# Bus
#----------------------------------------------------------
......@@ -62,7 +68,11 @@ class ImBus(models.Model):
@self.env.cr.postcommit.add
def notify():
with odoo.sql_db.db_connect('postgres').cursor() as cr:
cr.execute("notify imbus, %s", (json_dump(list(channels)),))
if ODOO_NOTIFY_FUNCTION:
query = sql.SQL("SELECT {}('imbus', %s)").format(sql.Identifier(ODOO_NOTIFY_FUNCTION))
else:
query = "NOTIFY imbus, %s"
cr.execute(query, (json_dump(list(channels)), ))
@api.model
def sendone(self, channel, message):
......
USA, 14 Sep 2023
IBM agrees to the terms of the Odoo Corporate Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Brad Topol btopol@us.ibm.com https://github.com/bradtopol
List of contributors:
Ludovic Gasc ludovic.gasc@be.ibm.com https://github.com/ludovic-gasc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment