I am deleting a record from a wizard action and return the same parent action( not wizard action) and showing the tree view properly.
But issue is in the latest URL in address bar(After deleting a record), a new parameter called active_id appeared with value of deleted record id.
URL before deleting the record
http://localhost:8069/web?debug=assets#id=160451&action=285&model=my.custom.model&view_type=form&cids=1&menu_id=125
URL after deleting the record
http://localhost:8069/web?debug=assets#active_id=897&model=my.custom.model&view_type=list&cids=&menu_id=125
Here u can see active_id=897 coming from somewhere, I think it is an ID of the wizard.
And an issue arise when I open a record and perform a button action getting the following error,
Record does not exist or has been deleted.
(Record: absent.info(898,), User: 398)
End of the button action of the wizard I tried to return in following ways, but nothing succeeded.
#Removed the active_id and active_ids from the context.
context = self.env.context.copy()
context.pop('active_id',None)
context.pop('active_ids',None)
keys_to_remove = ['active_id','active_ids']
action_id = self.env.ref('my_custom_action')
action_data = {'type': 'ir.actions.client', 'tag': 'reload'}
result = {'type': 'ir.actions.act_window_close'} # Optional: close the current window
return result, action_id
return {
'type': 'ir.actions.client',
'tag': 'reload',
}
return {
'type': 'ir.actions.act_window',
'res_model': 'my.custom.model',
'view_mode': 'tree,form',
'res_id': None,
# 'views': [(False, 'form')],
# 'target': 'new',
}
return action_id
return {
'name': 'Absent Info',
'type': 'ir.actions.act_window',
'view_mode': 'tree,form',
'res_model': 'absent.info',
# 'view_id':self.env.ref('fingent_hr_holidays.view_absent_info_tree').id,
'context': context,
# 'context': self._context,
'target': 'main',
}
How can I solve this?
I solved it by redirecting to a URL of the action. Here is the code.