Calendar 在Odoo中将合作伙伴添加到日历

Calendar 在Odoo中将合作伙伴添加到日历,calendar,openerp,openerp-8,Calendar,Openerp,Openerp 8,我需要在Odoo v.9中为用户的日历创建一个事件,但它不会创建与会者 event={ 'start':start_time.strftime('%Y-%m-%d %H:%M:%S'), 'stop':end_time.strftime('%Y-%m-%d %H:%M:%S'), 'duration':hours, 'allday':False, 'partner_ids': [emp.employee_id.id], 'name': myshif

我需要在Odoo v.9中为用户的日历创建一个事件,但它不会创建与会者

event={
    'start':start_time.strftime('%Y-%m-%d %H:%M:%S'),
    'stop':end_time.strftime('%Y-%m-%d %H:%M:%S'),
    'duration':hours,
    'allday':False,
    'partner_ids': [emp.employee_id.id],
    'name': myshift.account_id.name,
    'user_id': emp.employee_id.user_id.id,
  }
event=self.env['calendar.event'].create(event)

收集合作伙伴\u id与res.partner是一种多人关系,这是在calendar.event中写入合作伙伴id的方法?

您不能在多人字段中仅为其提供id而创建值(这仅适用于多人)。 如果该字段是一个2many或多个:

(0, 0, { values }) link to a new record that needs to be created with the given values dictionary
(1, ID, { values }) update the linked record with id = ID (write values on it)
(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID) link to existing record with id = ID (adds a relationship)
(5) unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

因此,您应该添加的不是列表,[(4,emp.employee\u id.id)]

您不能在多个字段中创建值,而只是给它一个id(这仅适用于多个字段)。 如果该字段是一个2many或多个:

(0, 0, { values }) link to a new record that needs to be created with the given values dictionary
(1, ID, { values }) update the linked record with id = ID (write values on it)
(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID) link to existing record with id = ID (adds a relationship)
(5) unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

因此,您应该添加的不是列表,[(4,emp.employee\u id.id)]

这是有效的代码

'partner_ids': [(4,[emp.employee_id.user_id.partner_id.id])],

这就是有效的代码

'partner_ids': [(4,[emp.employee_id.user_id.partner_id.id])],

谢谢,我到了,但是id是另一个型号的。现在它可以工作了:'partner_id':[(4,[emp.employee_id.user_id.partner_id.id])]谢谢,我已经知道了,但是这个id在另一个模型中。现在它可以工作了:'partner_id':[(4,[emp.employee_id.user_id.partner_id.id])]