Search code examples
odooodoo-11qwebodoo-view

Call a Specific form view of model in odoo js building Dashboard


I'm Building Dashboard when a particular div class clicked able to call the action against the class, but my issue is wanted to call specific form view for that js function. here is the code.

 action_my_profile: function(event) {
  var self = this;
  event.stopPropagation();
  event.preventDefault();
  this.do_action({
    name: _t("My Profile"),
    type: 'ir.actions.act_window',
    res_model: 'hr.employee',
    res_id: self.employee_data.id,
    view_mode: 'form',
    view_type: 'form',
    views: [[view_id, 'form']],
    context: {'edit': true},
    domain: [],
    target: 'inline'
  },{on_reverse_breadcrumb: function(){ return self.reload();}})
},

here is the issue that when a call this function open by default hr.employee(view_employee_form) but i want to open custom form which i created new one for the same model, i'm unable to resolve the issue. please help me out, thanks.


Solution

  • Try this way,you will get the specific view id and return to view it as per your request.

    action_my_profile: function(event) {
              var self = this;
              event.stopPropagation();
              event.preventDefault();
              self._rpc({
                        model: 'ir.model.data',
                        method: 'xmlid_to_res_id',
                        kwargs: {xmlid: 'youre_form_id'},
                    }).then(function (res_id) {
                          self.do_action({
                                name: _t("My Profile"),
                                type: 'ir.actions.act_window',
                                res_model: 'hr.employee',
                                res_id: self.employee_data.id,
                                view_mode: 'form',
                                view_type: 'form',
                                views: [[res_id, 'form']],
                                context: {'edit': true},
                                domain: [],
                                target: 'current'
                              },{on_reverse_breadcrumb: function(){ return self.reload();}})
    
                    },
                },