Python 2.7 如何在odoo中重写此方法?
我使用以下代码从自定义模块创建日历事件Python 2.7 如何在odoo中重写此方法?,python-2.7,openerp,odoo,odoo-8,openerp-8,Python 2.7,Openerp,Odoo,Odoo 8,Openerp 8,我使用以下代码从自定义模块创建日历事件 def create_calender_event(self,cr,uid,ids,context=None): calendar_obj = self.pool.get('calendar.event') for rec in self.browse(cr,uid,ids,context=context): if rec.action: for rec_res in rec.action
def create_calender_event(self,cr,uid,ids,context=None):
calendar_obj = self.pool.get('calendar.event')
for rec in self.browse(cr,uid,ids,context=context):
if rec.action:
for rec_res in rec.action:
calendar_obj.create(cr,uid,{'name' : rec_res.act_ion,
'user_id' : rec_res.asgnd_to.id,
'start_date' : fields.date.today(),
'stop_date' : rec_res.due_date,
'allday' : True,
'partner_ids' : [(6,0, [rec_res.asgnd_to.partner_id.id])]
},context=context)
return True
日历事件对象使用以下函数
def _send_mail_to_attendees(self, cr, uid, ids, email_from=tools.config.get('email_from', False),template_xmlid='calendar_template_meeting_invitation', force=False, context=None):
我想知道是否可以覆盖此方法并在上面的代码中设置自定义电子邮件模板,以便在创建日历事件期间发送的电子邮件将发送自定义电子邮件模板消息您可以在上下文中管理此设置变量。在ODOO8中,您可以这样修改上下文(您必须在调用
方法的函数中编写此函数-它可以是以下方法之一:发送邮件提醒
,创建与会者
,发送邮件
或类日历事件
的编写
方法:
一旦找到了调用函数并添加了我刚才编写的“和平代码”,就必须通过以下方式覆盖def\u send\u mail\u to\u attenders
:
def _send_mail_to_attendees(
self, cr, uid, ids, email_from=tools.config.get('email_from', False),
template_xmlid='calendar_template_meeting_invitation',
force=False, context=None):
if context.get('set_my_template', False):
template_xmlid = context.get('my_template_xml_id', False)
result = super(calendar_attendee, self)._send_mail_to_attendees(
cr, uid, ids, email_from, template_xmlid, force, context)
您可以在上下文中通过变量管理此设置。在Odoo 8中,您可以通过这种方式修改上下文(您必须在调用
方法的函数中编写此函数-它可以是以下方法之一:发送邮件提醒
,创建与会者
,发送邮件
或类日历事件
的编写
方法:
一旦找到了调用函数并添加了我刚才编写的“和平代码”,就必须通过以下方式覆盖def\u send\u mail\u to\u attenders
:
def _send_mail_to_attendees(
self, cr, uid, ids, email_from=tools.config.get('email_from', False),
template_xmlid='calendar_template_meeting_invitation',
force=False, context=None):
if context.get('set_my_template', False):
template_xmlid = context.get('my_template_xml_id', False)
result = super(calendar_attendee, self)._send_mail_to_attendees(
cr, uid, ids, email_from, template_xmlid, force, context)
Forvas非常感谢您的回答。不幸的是,我收到了这个错误AttributeError:“mom.meeting”对象没有属性“env”。函数
\u send\u mail\u attenders
在类日历中。attendeer
,不是吗?函数create\u calendar\u event
在您创建的类中。是mom.me吗eting
这个类的名称?(我的意思是,你的函数创建日历事件
是否在类内mom.meeting
)是的,它在类内,没有问题。将env替换为.\u context会解决问题吗?(实际上我已经从env改为.\u context)\u context
是一个快捷方式,所以应该是相同的。很抱歉,函数的代码是版本7,我没有意识到。我将编辑我的答案,看一下。没关系,实际上我正在尝试在V8上实现,有时也在v7上实现。我现在将尝试使用它。非常感谢:)Forvas非常感谢您的回答。不幸的是,我收到了这个错误AttributeError:“mom.meeting”对象没有属性“env”。函数\u send\u mail\u attenders
在类日历中。attendeer
,不是吗?函数create\u calendar\u event
在您创建的类中。是mom.me吗eting
这个类的名称?(我的意思是,你的函数创建日历事件
是否在类内mom.meeting
)是的,它在类内,没有问题。将env替换为.\u context会解决问题吗?(实际上我已经从env改为.\u context)\u context
是一个快捷方式,所以应该是相同的。很抱歉,函数的代码是版本7,我没有意识到。我将编辑我的答案,看一下。没关系,实际上我正在尝试在V8上实现,有时也在v7上实现。我现在将尝试使用它。非常感谢:)