İçereği Atla
Menü
Bu soru işaretlendi
1104 Görünümler

Hi everyone,


I'm configuring queue_job in Odoo to handle email sending so users don’t have to wait too long on the frontend. Below is my configuration in the config file:

ODOO_QUEUE_JOB_PORT=8069

workers = 4

server_wide_modules = base,web,queue_job

[queue_job]

channels = root:2


And here’s my Odoo code:


def _send_mail_accountant(self):
    for record in self:
        try:
            mail_id = (record.env.ref("purchase_qt3.mail_template_req_accountant", raise_if_not_found=False)
                       .with_context({'default_author_id': record.env.ref('base.partner_root').id})
                       .send_mail(record.id, force_send=False))
            mail_mail_id = record.env['mail.mail'].browse(mail_id)
            if mail_mail_id and mail_mail_id.state in ['exception', 'outgoing']:
                mail_mail_id.send()
            return True
        except Exception as e:
            raise UserError(f"Failed to send email: {e}")

def action_send_req_accountant(self):
    """
    Send a request to the accountant to confirm funding source
    :return:
    """
    for record in self:
        record.write({
            'state': 'await_accountant',
        })
        emails = record.env['ir.config_parameter'].sudo().get_param('purchase_qt3.x_email_to_accountant')
        if emails:
            emails = emails.split(',')
            if len(emails) > 1:
                record.write({
                    'x_email_to_accountant': emails[0],
                    'x_email_cc_accountant': ','.join(emails[1:]),
                })
            else:
                record.write({
                    'x_email_to_accountant': emails[0],
                })
            record.with_delay(priority=1)._send_mail_accountant()

The issue is that the emails are not being sent. After implementing this, when I click the button to send the email on the web interface, the user no longer has to wait for the page to load (which is good), but the emails are still not going out.



Here’s the error I’m seeing in the logs:


2025-02-26 15:41:05,699 11240 INFO ? odoo.addons.queue_job.jobrunner.runner: initializing database connections

2025-02-26 15:41:05,789 11240 INFO ? odoo.addons.queue_job.jobrunner.runner: queue job runner ready for db CHECK_3

2025-02-26 15:41:05,789 11240 INFO ? odoo.addons.queue_job.jobrunner.runner: database connections ready

2025-02-26 15:41:05,789 11240 ERROR ? odoo.addons.queue_job.jobrunner.runner: exception: sleeping 5s and retrying

Traceback (most recent call last):

  File "d:\study\python_code\odoo_16\server\addons_qt3_cs\tienich\queue_job\jobrunner\selectors.py", line 314, in _select

    r, w, x = select.select(r, w, w, timeout)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

OSError: [WinError 10038] An operation was attempted on something that is not a socket


Why aren’t the emails being sent? It seems like queue_job is preventing the jobs from running properly. Has anyone encountered this issue or have any suggestions on how to fix it? I’m running this on Windows with Odoo 16.



Thanks in advance for your help!

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Ağu 25
500
1
May 25
1303
0
Kas 24
1406
2
Eki 24
1488
0
Ağu 24
1246