Help

2

Sending message from cron job

Avatar
Yakoub Klai

Hello,

I have a cron job monitoring the deadline of certain documents and supposedly sending alert messages to the user.
Running the function manually causes no problems at all.
When ran as a cron job, the function runs in an endless loop with the following exception message in the console :

Traceback (most recent call last):
  File "/opt/odoo/odoo-10.0/odoo/addons/base/ir/ir_cron.py", line 235, in _acquire_job
    registry[cls._name]._process_job(job_cr, job, lock_cr)
  File "/opt/odoo/odoo-10.0/odoo/addons/base/ir/ir_cron.py", line 168, in _process_job
    job_cr.commit()
  File "/opt/odoo/odoo-10.0/odoo/sql_db.py", line 141, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/odoo-10.0/odoo/sql_db.py", line 365, in commit
    func()
  File "/opt/odoo/odoo-10.0/addons/mail/models/res_partner.py", line 236, in send_notifications
    env = api.Environment(cr, SUPERUSER_ID, {})
  File "/opt/odoo/odoo-10.0/odoo/api.py", line 726, in __new__
    env, envs = None, cls.envs
  File "/opt/odoo/odoo-10.0/odoo/tools/func.py", line 111, in __get__
    return self.fget.__get__(None, owner)()
  File "/opt/odoo/odoo-10.0/odoo/api.py", line 699, in envs
    return cls._local.environments
  File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 71, in __getattr__
    raise AttributeError(name)
AttributeError: environments


Apparently a problem while committing the cron job.

When I comment the message_post call the cron runs with no problems.

What can be the cause of this problem and how can I fix it?

1 Comment
Avatar
Discard

Can you please post the full code of your cron/function?

1 Answer
1
Avatar
Yakoub Klai
Best Answer

Avatar
Discard