mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 14:32:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright 2020 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
# this is the trigger that sends notifications when jobs change
|
||||
logger.info("Create queue_job_notify trigger")
|
||||
cr.execute(
|
||||
"""
|
||||
DROP TRIGGER IF EXISTS queue_job_notify ON queue_job;
|
||||
CREATE OR REPLACE
|
||||
FUNCTION queue_job_notify() RETURNS trigger AS $$
|
||||
BEGIN
|
||||
IF TG_OP = 'DELETE' THEN
|
||||
IF OLD.state != 'done' THEN
|
||||
PERFORM pg_notify('queue_job', OLD.uuid);
|
||||
END IF;
|
||||
ELSE
|
||||
PERFORM pg_notify('queue_job', NEW.uuid);
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
CREATE TRIGGER queue_job_notify
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON queue_job
|
||||
FOR EACH ROW EXECUTE PROCEDURE queue_job_notify();
|
||||
"""
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue