I have written a constraint for a particular field and I want to refresh the view of calendar when the constraint fails.
Below is the code I had tried
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']),
]
If the constraint fails(i.e at the return False), I want to refresh the calendar view.
Anyone with idea kindly please guide me with some idea.
I want to drag that(Green Arrow) meeting event
After Drag and Drop, Constraint message will display
When I click on OK button of warning message, event does not move to its original place
I want calendar to reload when i click on OK button