This code below is working when I run it manually but my scheduled action is not triggering automatically. scheduler user is set to me but for rest of the scheduled actions its OdooBot. Why am I facing this issue and how to solve this?
Im using odoo 15 on odoosh which we moved recently, below is the minified code - use chatgpt to make it understandable this wont let me post coz of low karma.
Code: template = env['mail.template'].search([('name', '=', 'Test - Due date reminder for CRM Activity')], limit=1);
if not template.exists(): raise UserError("Template 'Test - Due date reminder for CRM Activity' not found!");
activities = env['mail.activity'].search([('res_model', '=', 'crm.lead'), ('date_deadline', '=', datetime.date.today()), ('user_id', '!=', False)]);
log_messages = [];
[log_messages.append(f"Preparing email for activity: {activity.id} User: {activity.user_id.name}") or (email_content := f"<p>Dear {activity.user_id.name},</p><p>This is a reminder that you have an activity due today.</p><p>Opportunity: {activity.res_name}</p><p>Activity Type: {activity.activity_type_id.name}</p><p>Due Date: {activity.date_deadline}</p><p>Activity Subject: {activity.summary}</p><p>Description: {activity.note or 'No additional notes.'}</p><p>Thank you!</p>", email_subject := f"Reminder: You have an activity due today for {activity.activity_type_id.name}", email := env['mail.mail'].create({'subject': email_subject, 'body_html': email_content, 'email_to': activity.user_id.email, 'auto_delete': False}), email.send(), log_messages.append(f"Email sent to: {email.email_to} for activity: {activity.id}") if not log_messages else None) for activity in activities];
if log_messages: raise UserError("\n".join(log_messages))