mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-20 00:12:04 +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,47 @@
|
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
with api.Environment.manage():
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
_logger.info("Computing exception name for failed jobs")
|
||||
_compute_jobs_new_values(env)
|
||||
|
||||
|
||||
def _compute_jobs_new_values(env):
|
||||
for job in env["queue.job"].search(
|
||||
[("state", "=", "failed"), ("exc_info", "!=", False)]
|
||||
):
|
||||
exception_details = _get_exception_details(job)
|
||||
if exception_details:
|
||||
job.update(exception_details)
|
||||
|
||||
|
||||
def _get_exception_details(job):
|
||||
for line in reversed(job.exc_info.splitlines()):
|
||||
if _find_exception(line):
|
||||
name, msg = line.split(":", 1)
|
||||
return {
|
||||
"exc_name": name.strip(),
|
||||
"exc_message": msg.strip("()', \""),
|
||||
}
|
||||
|
||||
|
||||
def _find_exception(line):
|
||||
# Just a list of common errors.
|
||||
# If you want to target others, add your own migration step for your db.
|
||||
exceptions = (
|
||||
"Error:", # catch all well named exceptions
|
||||
# other live instance errors found
|
||||
"requests.exceptions.MissingSchema",
|
||||
"botocore.errorfactory.NoSuchKey",
|
||||
)
|
||||
for exc in exceptions:
|
||||
if exc in line:
|
||||
return exc
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo.tools.sql import column_exists, table_exists
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if table_exists(cr, "queue_job") and not column_exists(
|
||||
cr, "queue_job", "exec_time"
|
||||
):
|
||||
# Disable trigger otherwise the update takes ages.
|
||||
cr.execute(
|
||||
"""
|
||||
ALTER TABLE queue_job DISABLE TRIGGER queue_job_notify;
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
"""
|
||||
ALTER TABLE queue_job ADD COLUMN exec_time double precision DEFAULT 0;
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
"""
|
||||
UPDATE
|
||||
queue_job
|
||||
SET
|
||||
exec_time = EXTRACT(EPOCH FROM (date_done - date_started));
|
||||
"""
|
||||
)
|
||||
cr.execute(
|
||||
"""
|
||||
ALTER TABLE queue_job ENABLE TRIGGER queue_job_notify;
|
||||
"""
|
||||
)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
|
||||
from openupgradelib import openupgrade
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
# Remove cron garbage collector
|
||||
openupgrade.delete_records_safely_by_xml_id(
|
||||
env,
|
||||
["queue_job.ir_cron_queue_job_garbage_collector"],
|
||||
)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo.tools.sql import table_exists
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if table_exists(cr, "queue_job"):
|
||||
# Drop index 'queue_job_identity_key_state_partial_index',
|
||||
# it will be recreated during the update
|
||||
cr.execute("DROP INDEX IF EXISTS queue_job_identity_key_state_partial_index;")
|
||||
Loading…
Add table
Add a link
Reference in a new issue