如何在odoo中返回表单编辑视图?

Man*_*ani 4 openerp odoo-8 odoo-9

在下面的代码适用于窗体视图

search_ids = self.env['sale.order'].search([])
last_id = search_ids and max(search_ids)        
return {
    'name': _('Revise Quote'),
    'view_type': 'form',
    'view_mode': 'form',
    'res_model': 'sale.order',
    'res_id': last_id.id,
    'type': 'ir.actions.act_window',
}
Run Code Online (Sandbox Code Playgroud)

如何重定向到编辑视图?

在此处输入图片说明

dge*_*iev 6

在日历模块中,我可以看到它们返回了另一个键'flags'

编辑:我有机会测试它,因为我收到了类似的任务,因此我可以确认下面的方法flags可以解决问题。

日历/calendar.py

def open_after_detach_event(self, cr, uid, ids, context=None):
    ...
    return {
        'type': 'ir.actions.act_window',
        'res_model': 'calendar.event',
        'view_mode': 'form',
        'res_id': new_id,
        'target': 'current',
        'flags': {'form': {'action_buttons': True, 'options': {'mode': 'edit'}}}
    }
Run Code Online (Sandbox Code Playgroud)