运行cron作业以发送计划的邮件时,Odoo缺少错误 [英] Odoo Missing Error while running a cron job for sending scheduled mail

查看:114
本文介绍了运行cron作业以发送计划的邮件时,Odoo缺少错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码.当调度程序运行时,我收到错误消息.有人帮我解决了代码中的错误

I have the following code. When the scheduler runs I am getting the error message. Some one help me to resolve the error in the code

MissingError 您尝试访问的文档之一已被删除,请刷新后重试.

MissingError One of the documents you are trying to access has been deleted, please try again after refreshing.

def send_followup_mail(self, cr, uid, context=None):
        quot_ids=self.search(cr, uid, [('state','=','amend_quote')])
        for quot_id in quot_ids:
            if quot_id:
                quot_obj=self.browse(cr, uid, quot_id ,context=context)
                quotation_since=quot_obj.quotation_since
                for email_template_line in quot_obj.temp_tag_id.crm_campaign_id.email_template_ids:
                    if quotation_since==email_template_line.delay_days:
                        mail_pool = self.pool.get('mail.mail')
                        mail_id = self.pool.get('email.template').send_mail(cr, uid, email_template_line.id, 1, force_send=True, context=context)

                        if email_template_line.send_mail_to=='to_client':
                            mail_pool.write(cr, uid, mail_id, {'email_to':quot_obj.email_from}, context=context)

                        elif email_template_line.send_mail_to=='to_sale_rep':
                            mail_pool.write(cr, uid, mail_id, {'email_to':quot_obj.sale_rep_id.email}, context=context)

                        if mail_id:
                            mail_pool.send(cr, uid, mail_id, context=context)
                self.write(cr, uid, quot_id,{'quotation_since':quotation_since+1}, context=None)
        return True

推荐答案

这是经过修改的代码,可以正常工作

This is the modified code and works fine

def send_followup_mail(self, cr, uid, context=None):
            quot_ids=self.search(cr, uid, [('state','=','amend_quote')])
            for quot_id in quot_ids:
                if quot_id:
                    quot_obj=self.browse(cr, uid, quot_id ,context=context)
                    quotation_since=quot_obj.quotation_since
                    for email_template_line in quot_obj.temp_tag_id.crm_campaign_id.email_template_ids:
                        if quotation_since==email_template_line.delay_days:
                            mail_pool = self.pool.get('mail.mail')
                            template_id = email_template_line.id
                            template_pool = self.pool.get('email.template')
                            sale_id=self.pool.get('sale.order').search(cr, uid, [], limit=1, context=context)
                            mail_id = template_pool.send_mail(cr, uid, template_id, sale_id[0], force_send=True, context=context)

                            if email_template_line.send_mail_to=='to_client':
                                mail_pool.write(cr, uid, mail_id, {'email_to':quot_obj.email_from}, context=context)

                            elif email_template_line.send_mail_to=='to_sale_rep':
                                mail_pool.write(cr, uid, mail_id, {'email_to':quot_obj.sale_rep_id.email}, context=context)

                            if mail_id:
                                mail_pool.send(cr, uid, mail_id, context=context)
                    self.write(cr, uid, quot_id,{'quotation_since':quotation_since+1}, context=None)
            return True

这篇关于运行cron作业以发送计划的邮件时,Odoo缺少错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆