打电话 on_change_opportunity,改变机会 date_action

Phonecall on_change_opportunity, change opportunities date_action

我们在 crm.phonecall.py 中有 on_change_opportunity 方法。我想知道(并试图)做到这一点,如果您将机会添加到预定的通话中,那么该机会的 date_action(下一个操作日期)将变成预定通话的日期。

def on_change_opportunity(self, cr, uid, ids, opportunity_id, context=None):
    values = {}
    if opportunity_id:
        opportunity = self.pool.get('crm.lead').browse(cr, uid, opportunity_id, context=context)
        values = {
            'section_id' : opportunity.section_id and opportunity.section_id.id or False,
            'partner_phone' : opportunity.phone,
            'partner_mobile' : opportunity.mobile,
            'partner_id' : opportunity.partner_id and opportunity.partner_id.id or False,
        }
    return {'value' : values}

我尝试添加一行: opportunity.date_action = self.date.strftime('%Y-%m-%d') 这显然行不通。如何进行?

编辑。我得到的错误是 AttributeError: 'crm.phonecall' object has no attribute '_ids'

def on_change_opportunity(self, cr, uid, ids, opportunity_id, context=None):
values = {}
if opportunity_id:
    opportunity = self.pool.get('crm.lead').browse(cr, uid, opportunity_id, context=context)
    values = {
        'section_id' : opportunity.section_id and opportunity.section_id.id or False,
        'partner_phone' : opportunity.phone,
        'partner_mobile' : opportunity.mobile,
        'partner_id' : opportunity.partner_id and opportunity.partner_id.id or False,
    }

    phonecall = self.browse(cr, uid, ids, context=context)
    if phonecall:
        date = phonecall[0].date
        opportunity.write({'date_action': date})

return {'value' : values}