odoo/odoo#194776

Created by fw-bot
Merged at c8b12a6012f1889579dda95ade9b3f23ed702248

Statuses:

label
odoo-dev:saas-18.1-18.0-fix-opw-4474171-juwu-GufJ-fw
head
04b57d6a015682ab32ea2782b7bdcf14df1a7237
merged
4 months ago by Junqi Wu (juwu)
odoo/odoo
18.0 #194233
saas-18.1 #194776
saas-18.2
saas-18.3
master #194779

[FW][FIX] mail: correctly restart scheduled message cron

Before this commit, mail.ir_cron_post_scheduled_message fails with a traceback when there are a lot of scheduled messages to be sent.

Steps to reproduce

  1. Create a scheduled message from the chatter full composer
  2. Duplicate it 50+ times
  3. Run the scheduled action "Mail: Post scheduled messages"
  4. Traceback occurs
File "/home/odoo/src/odoo/odoo/api.py", line 553, in __new__
assert isinstance(cr, BaseCursor)
^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Cause

This commit (df18d5257cef737f3e1d245a8b85769e1fe1a032) introduced this cron which posts past-due scheduled messages with a default limit=50. If there are more messages than the limit, the cron is triggered again. However, there is a typo when restarting the cron that incorrectly calls env.

Solution

Change the line to use env.ref() to correctly access the xml_id and restart the cron.

opw-4474171

Forward-Port-Of: #194233