Skip to Content
Menu
Dette spørgsmål er blevet anmeldt

Hello,

I am facing the following issue:

I have a cron job that runs perfectly on our development instance. On dev, it takes around 20 minutes to complete. However, when I start it manually on our production instance, it completes instantly without actually performing any work.

Here are the logs from the production instance when I trigger the job manually:

2025-09-12 15:06:37,827 1044751 INFO webx odoo.addons.base.models.ir_cron: Manually starting job `OrgaMax Sync`.
2025-09-12 15:06:37,829 1044751 INFO webx odoo.addons.base.models.ir_cron: Job `OrgaMax Sync` done.

Notice that there are no errors in the logs or in the UI.

Cron job XML definition:

<odoo>
    <record id="orgamax_sync" model="ir.cron">
        <field name="name">OrgaMax Sync</field>
        <field name="active" eval="True"/>
        <field name="state">code</field>
        <field name="model_id" ref="model_orgamax_sync"/>
        <field name="code">model.sync_customers()</field>
        <field name="interval_number">1</field>
        <field name="interval_type">days</field>
        <field name="user_id" ref="base.user_root"/>
        <field name="priority">1</field>
    </record>
</odoo>

Model snippet:

import fdb
import logging
import time
from odoo import models, api

_logger = logging.getLogger(__name__)

class OrgaMaxSync(models.Model):
    _name = "orgamax_sync"
    _description = "Sync customers from OrgaMax to Odoo"

    @api.model
    def sync_customers(self):
        _logger.info("STARTING JOB")
        start = time.time()
        ...

The rest of the sync_customers code is not very relevant since, as you can see, the log message "STARTING JOB" is never printed on production.
But there is error handling in the form of Try Except blocks which also log any erros using _logger.error

Module structure:

__manifest__.py
{
    "name": "OrgaMaxSync",
    "data": [
        "data/ir_cron_data.xml"
    ]
}

__init__.py
from . import models

models/__init__.py
from . import OrgaMaxSync

The even stranger part is that this cron used to run on production but would eventually timeout. To fix that, I increased the CPU time in odoo.conf to 30 minutes. After that, the cron started behaving this way. I reverted the odoo.conf settings back to the previous state, but the cron job still finishes instantly.

I also tried setting the next execution time in the UI to 5 minutes in the future, but it still does not execute automatically. The cron is enabled (active=True).

I am on Odoo 17.

Has anyone experienced this before or have any idea why the cron would immediately finish without logging anything?

Avatar
Kassér
Bedste svar

Hi,


On development, the cron job runs fine and takes about 20 minutes, but on production it finishes instantly without doing any work and the expected log message never appears. The cron used to run but stopped after changes were made to the odoo.conf file. Reverting the configuration didn’t fix the problem, and no errors show up in the logs or the UI.


The most likely causes are that the cron record is no longer correctly linked to the model, the model is not imported or loaded properly, the cron is running under a user with insufficient permissions, the cron registry cache has not refreshed, or the cron record itself has become corrupted.


To debug, you should check the scheduled action in Settings → Technical → Automation → Scheduled Actions to confirm the model and code are correct. You can also test in Odoo Shell whether the model orgamax_sync exists and whether calling sync_customers() directly works. If it does, the issue lies in the cron link; if not, the model may not be loaded. Changing the cron user, forcing a module reload with -u, or deleting and recreating the cron are recommended next steps.


In summary, the issue comes down to the cron record not being correctly tied to the model or method in production. Recreating or updating the scheduled action so it points properly to orgamax_sync.sync_customers should resolve the problem.


Hope it helps

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
2
aug. 25
439
2
jun. 25
908
1
mar. 25
1261
2
jul. 25
846
1
jun. 25
940