4
votes

I have a view that list a lot of items. When the user selects anyone, an edition wizard appears with extended functionallity. Some actions of the wizard make it closed but parent view is not refreshed shows the old data.

I need that an action performed in a button of an OpenERP wizard view refresh the parent view.

I have tried:

def some_action(self, cr, uid, ids, context=None):
    ....
    res = {'type':'ir.actions.act_window_close', 'auto_refresh':'1' }
    return res

and tried this:

def some_action(self, cr, uid, ids, context=None):
    ....
    win_obj = self.pool.get('ir.actions.act_window')
    res = win_obj.for_xml_id(cr, uid, 'parent_module', 'parent_view', context)
    res = {'type':'ir.actions.act_window_close', 'auto_refresh':'1' }
    return res

and this:

def some_action(self, cr, uid, ids, context=None):
    ...
    mod_obj = self.pool.get('ir.model.data')
    view_rec = mod_obj.get_object_reference(cr, uid, 'hr_holidays', 'open_ask_holidays')
    view_id = view_rec and view_rec[1] or False
    return {
       'view_type': 'form',
       'view_id' : [view_id],
       'view_mode': 'form',
       'res_model': 'model.obj.here',
       'type': 'ir.actions.act_window',
       'context': context
    } 

but nothing works...

2

2 Answers

6
votes

The correct form is:

def some_action(self, cr, uid, ids, context=None):
    ....
    res = { 'type': 'ir.actions.client', 'tag': 'reload' }
    return res

I found it here:

"How to refresh the original view after wizard actions?". OpenERP Knowledge base

3
votes

Following @yucer provided link I found that it is possible to refresh fields values without reloading the view.

openerp.your_module_name = function (instance) {
    instance.web.ActionManager = instance.web.ActionManager.extend({

        ir_actions_act_close_wizard_and_refresh_view: function (action, options) {
            if (!this.dialog) {
                options.on_close();
            }
            this.dialog_stop();
            this.inner_widget.views[this.inner_widget.active_view].controller.reload();
            return $.when();
        },
    });
}

Call the action when closing the wizard view:

return { 'type' :  'ir.actions.act_close_wizard_and_refresh_view' }