问题
Trying to create an calendar event on the click of a button in my custom module.
python code is as follows:
class mom_meeting(osv.Model):
_name = "mom.meeting"
_rec_name = 'meet_ref'
_inherit = 'mail.thread'
STATUS_SELECTION=[
('Block A - Board Room', 'Block A - Board Room'),
('Block B - Board Room', 'Block B - Board Room'),
('Block B - Discussion Room - 1', 'Block B - Discussion Room - 1'),
('Block B - Discussion Room - 2', 'Block B - Discussion Room - 2'),
]
_columns = {
'ch_prsn': fields.many2one('hr.employee','Chair Person',required=True),
'prj_name': fields.char('Project Name',size=45,required=True),
'mdt': fields.datetime('Date',required=True),
'min_prp':fields.many2one('hr.employee','Minutes Prepared',required=True),
'loc':fields.selection(STATUS_SELECTION,'Location',required=True),
'nxt_mt':fields.datetime('Start'),
'nxt_mt_end':fields.datetime('Stop'),
'pom':fields.text(''),
'matp':fields.one2many('mom.person','ename_id','Employee name'),
'newa':fields.one2many('mom.new','ename_i','New Attendees'),
'meet_agenda':fields.one2many('mom.agenda','meetin_agenda','Meeting Agenda'),
'meet_notes':fields.text(''),
'depat':fields.char('Department'),
'action':fields.one2many('mom.action','meeting_id','Action Items'),
'meet_ref': fields.many2one('calendar.event', 'Meeting ID',required=True),
'emp_name': fields.many2one('hr.employee','New attendee'),
'url': fields.function(_get_url, type='char', string='Url'),
}
def create_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.nxt_mt:
calendar_obj.create(cr,uid,{'name' : rec.meet_ref.name,
'user_id' : rec.min_prp.user_id.id,
'start_datetime' : rec.nxt_mt,
'stop_datetime' : rec.nxt_mt_end,
},context=context)
return True
Now there is a attendees field in Calendar and i wanted to merge values of two one2many(two one2many fields are 'matp' and 'newa') fields of different classes and assign the values to 'attendee_ids' for a new calendar event that is getting created.
Anyone with any idea on this would be very helpful.
来源:https://stackoverflow.com/questions/34938923/how-to-achieve-the-following-scenario-in-odoo