[Odoo][v10] 在 Odoo v10 中为来自 Python 的关注者添加订阅类型
[Odoo][v10] Add subscription types for a follower from Python in Odoo v10
我构建自己的模块,并为每个项目添加一个日历事件,其中包含来自该项目的关注者。
所以我写了一个方法:
def create_calendar_event(self):
create_event = self.env['calendar.event'].create({'start': self.start_date, 'stop': self.end_date, 'name': self.title})
self.calendar_id = create_event
partner_list = []
for follower in self.project_id.message_follower_ids:
partner_list.append(follower.partner_id.id)
self.testfield = str(partner_list) # Debug
calendar_fallowers = []
for follower2 in self.calendar_id.message_follower_ids:
calendar_fallowers.append(follower2.partner_id.id)
self.testfield_calendar = str(calendar_fallowers) # Debug
# add followers from project to calendar
for partner in partner_list:
if partner not in calendar_fallowers:
res_id = self.calendar_id.id
res_model = 'calendar.event'
partner_id = partner
self.env['mail.followers'].create({'res_id': res_id, 'res_model': res_model, 'partner_id': partner_id})
self.env.cr.commit()
所以我有带关注者的日历活动,但我没有任何默认订阅类型。
我想为所有关注者添加默认订阅类型:讨论和注释
如何操作?
添加关注者odoo提供了一个方法:
self.calendar_id.message_subscribe(partner_list)
并移除追随者:
some_record.message_unsubscribe(partner_list)
我构建自己的模块,并为每个项目添加一个日历事件,其中包含来自该项目的关注者。
所以我写了一个方法:
def create_calendar_event(self):
create_event = self.env['calendar.event'].create({'start': self.start_date, 'stop': self.end_date, 'name': self.title})
self.calendar_id = create_event
partner_list = []
for follower in self.project_id.message_follower_ids:
partner_list.append(follower.partner_id.id)
self.testfield = str(partner_list) # Debug
calendar_fallowers = []
for follower2 in self.calendar_id.message_follower_ids:
calendar_fallowers.append(follower2.partner_id.id)
self.testfield_calendar = str(calendar_fallowers) # Debug
# add followers from project to calendar
for partner in partner_list:
if partner not in calendar_fallowers:
res_id = self.calendar_id.id
res_model = 'calendar.event'
partner_id = partner
self.env['mail.followers'].create({'res_id': res_id, 'res_model': res_model, 'partner_id': partner_id})
self.env.cr.commit()
所以我有带关注者的日历活动,但我没有任何默认订阅类型。
我想为所有关注者添加默认订阅类型:讨论和注释
如何操作?
添加关注者odoo提供了一个方法:
self.calendar_id.message_subscribe(partner_list)
并移除追随者:
some_record.message_unsubscribe(partner_list)