This question has been flagged
10 Replies
27173 Views

Consider there is a form view say sale order. In sale order , there is a button which is not in its header...call button A. When button A clicks, it pop ups the wizard, wizard consists of a button say B. B having some functionality to update in the master or source record ie, in sale order. So when B clicks, it executes the function and wizard gets closed.

So my requirement is button B should not close the wizard after executing the function and source/ master record gets refreshed(source record: sale order form) in the button action itself.

Avatar
Discard
Best Answer

Hi Jasad,

As far as I know there is no such functionality in the framework at the moment. However, you can try with the following ActionManager extension which should be defined in the JS file within your module

Here for example: 'static/src/js/your_module_name.js'

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

        ir_actions_act_close_wizard_and_reload_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();
        },
    });
}

To use this action just return following when closing a wizard:

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

I hope this helps :-)

Cheers, Petar

Avatar
Discard

Thanks Man. That Helped.. :)

This action close works for ir.actions.act_window but not work for ir.actions.client? How to close the ir.actions.client to close? Thanks in advance.

Best Answer

FOR VERSION 13 2020

    ActionManager.include({

        _handleAction: function (action, options) {

            if (action.type === 'ir.actions.act_close_wizard_and_reload_attachments') {

                return this.ir_actions_act_close_wizard_and_reload_attachments();

            }

            return this._super(action, options);

        },


        ir_actions_act_close_wizard_and_reload_attachments: function (action, options) {

           this._closeDialog();

           //this.getCurrentController().widget.renderer.chatter._onReloadAttachmentBox();
            //reload your own object view or widget

        },

    });

in python
      return {'type': 'ir.actions.act_close_wizard_and_reload_attachments'}

Avatar
Discard
Best Answer

use this

return {
    'type': 'ir.actions.client',
    'tag': 'reload',  }
Avatar
Discard
Author

Hi Sayed, This will reload the entire application. I dont want to do so. Just refreshing the main window.

Best Answer

I have gone from OpenERP 6.1 to Odoo11.
In OpenERP, nothing special was needed.
In Odoo11 I tried what he says Alexandro, but I do not get the expected performance.
Is there any way to get it in Odoo11?

Avatar
Discard

Hi Isidre,

This action was eventually converted into it's own module (``web_ir_actions_act_view_reload``) over at OCA github repository: https://github.com/OCA/web

You can use it with Odoo versions 11.0 and 12.0.

Kind Reagards,

Petar

Best Answer

Not working on odoo v9:

Action manager can't handle action of type ir.actions.act_close_wizard_and_refresh_view

  1. {flags: {…}, type: "ir.actions.act_close_wizard_and_refresh_view", context: {…}, menu_id: null}
    1. context:
      1. active_id:3
      2. active_ids:Array(1)
        1. 0:3
        2. length:1
        3. __proto__:Array(0)
      3. active_model:"sale.manage.variant"
      4. lang:"es_AR"
      5. params:{action318id9view_type"form"model"sale.order"_push_mefalse}
      6. search_disable_custom_filters:true
      7. tz:"Europe/Brussels"
      8. uid:1
      9. __proto__:Object
    2. flags:
      1. __proto__:Object
    3. menu_id:null
    4. type:"ir.actions.act_close_wizard_and_refresh_view"
    5. __proto__:
      1. constructor:ƒ Object()
      2. hasOwnProperty:ƒ hasOwnProperty()
      3. isPrototypeOf:ƒ isPrototypeOf()
      4. propertyIsEnumerable:ƒ propertyIsEnumerable()
      5. toLocaleString:ƒ toLocaleString()
      6. toString:ƒ toString()
      7. valueOf:ƒ valueOf()
      8. __defineGetter__:ƒ __defineGetter__()
      9. __defineSetter__:ƒ __defineSetter__()
      10. __lookupGetter__:ƒ __lookupGetter__()
      11. __lookupSetter__:ƒ __lookupSetter__()
      12. get __proto__:ƒ __proto__()
      13. set __proto__:ƒ __proto__()


Any idea why the action is not called?

Avatar
Discard
Best Answer

Continuing the work mentioned previously, the following works on Odoo 9:


odoo.define('my_module.action_manager', function(require) { 
  var action_manager = require('web.ActionManager');
  var MyModuleActionManager = action_manager.include({
    ir_actions_act_close_wizard_and_reload_view: function (action, options) {
      if (!this.dialog) {
        options.on_close();
      }
      this.dialog_stop();
      this.inner_widget.active_view.controller.do_reload();
      return $.when();
    },
  });
  return MyModuleActionManager; });
Avatar
Discard