如何在Odoo中实现以下场景?

时间:2016-01-22 04:17:10

标签: python-2.7 openerp openerp-7 odoo-8

尝试在我的自定义模块中单击按钮创建日历事件。

python代码如下:

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

现在日历中有一个与会者字段,我想要合并两个one2many(两个one2many字段是' matp'和' newa')不同类的字段的值并分配值为' attendee_ids'对于正在创建的新日历事件。

任何对此有任何想法的人都会非常有帮助。

0 个答案:

没有答案