7

I have created a button in jobs by using inheritance in (hr.recruitment form view) , how could I open another module("Resumes and Letters -sub menu in Human Resource " ) form_view during buttons click event is done.my aim is that I just want open that form when this click event done.

Is it possible to solve? Need help please

Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48
PKS ks
  • 116
  • 1
  • 3
  • 8
  • There are many screen in odoo where you click on a button and wizard/popup is shown, try to surf through those screen and try to find how that works. example: Customer Invoice screen where you find a button to do the payment, which opens a popup. Here you just need to apply little bit of effort to search through odoo core code and you will find your answer. – Hardik Patadia Aug 11 '15 at 14:46

2 Answers2

10

yes, it is possible to open another window. you have to do like this.

@api.multi
def button_method(self):
    return {
        'type': 'ir.actions.act_window',
        'name': 'form name',
        'res_model': 'object name',
        'res_id': id ,
        'view_type': 'form',
        'view_mode': 'form',
        'target' : 'new',
        }

but it is possible when record save. if you want to open wizard before save record you have to code in js like this.

in js file: openerp.module_name = function(instance) {

var QWeb = openerp.web.qweb;
    _t = instance.web._t;

instance.web.View.include({
    load_view: function(context) {
        var self = this;
        var view_loaded_def;
        $('#oe_linking_e').click(this.on_preview_view_button);

 //this is button class which call method for open your form.

       return self._super(context);
    },

//method which open form

    on_preview_view_button: function(e){
        e.preventDefault();
            this.do_action({
                name: _t("View name"),
                type: "ir.actions.act_window",
                res_model: "object",
                domain : [],
                views: [[false, "list"],[false, "tree"]],
                target: 'new',
                context: {},
                view_type : 'list',
                view_mode : 'list'
            });
        }
    },
});
};

in xml file add button and give id="oe_linking_e" whatever you give in js code.

Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48
  • Sorry to ask here. How can I get `view_id` dynamically on js so later i can use it as dictionary parameter on `do_action`?. I know how to do it in python but not in js. – Agung Setiawan May 19 '16 at 13:48
5

you can return form in this manner.
In your button method return this dictionary. It will open the target form in a pop-up window ,

def button_method(...........):
    return {
              'name': _(some name),
              'view_type': 'form',
              "view_mode": 'form',
              'res_model': model-name,
              'type': 'ir.actions.act_window',
              'target': 'new',
              }

you can pass <br> 'res_id': target_id in the above dictionary to open a particular record

Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48