是否可以在Odoo 8中的约束函数中以编程方式刷新模型的视图?

Shr*_*tty 10 javascript openerp python-2.7

我已经为特定字段写了一个约束,我想在约束失败时刷新日历视图.

下面是我试过的代码

def _check_date_drag(self, cr, uid, ids, context=None):
        mom_obj = self.pool.get('mom.meeting')
    res = {}
    for item in self.browse(cr, uid, ids):
        mom_ids = mom_obj.search(cr, uid, 
[('meet_ref','=',item.number), ('mdt','<',item.start_datetime)], 
context=context)
        if mom_ids:
            res = {
                  'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'calendar.event',
                'type': 'ir.actions.act_window',
                'target': 'new',
            }
            return False and res
    return True



    _constraints = [

        (_check_date_drag, 'MOM is already created for this calendar 
event! Kindly refresh the page to discard the changes!', 
['start_datetime']),
    ]
Run Code Online (Sandbox Code Playgroud)

如果约束失败(即返回False),我想刷新日历视图.

任何有想法的人请引导我一些想法.我想拖动那个(绿色箭头)会议活动 我想拖动那个(绿色箭头)会议活动 拖放后,将显示Constraint消息 拖放后,将显示Constraint消息 当我点击警告信息的确定按钮时,事件不会移动到其原始位置 当我点击警告信息的确定按钮时,事件不会移动到其原始位置

我想在点击"确定"按钮时重新加载日历

dge*_*iev 1

您可以尝试以下方法之一(未经测试):

1) 添加一些 javascript 以刷新对话关闭时的视图。

2)捕获约束错误,并返回操作以显示相同的视图(本质上刷新页面)。传递上下文中的错误信息,使视图最终显示上下文中的错误。这样,当执行因错误而停止时,刷新的页面就已经在那里了。

希望对你有帮助。