Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

I have a custom button near list view and opened the action from javascript with target:new and it worked when record is single as i have passed the id of the record and it opened the form view on button click but when there are multiple records, I have opened the tree view and displayed all records in case of multiple and clicked on record but doesn't opened the form view of the particular record.


here is my code:-


odoo.define('module_name.file_name', function (require) {
"use strict";
var ListController = require('web.ListController');
var ListView = require('web.ListView');
var viewRegistry = require('web.view_registry');
var rpc = require('web.rpc');
var test = [];
var count_doc = 0;
var TreeButton = ListController.extend({
   buttons_template: 'button_template.buttons',
   events: _.extend({}, ListController.prototype.events, {
   'click .button_class': '_OpenWizardAttendance',
  }),
  _OpenWizardAttendance: function () {
   var self = this;
   rpc.query({
        model: 'hr.attendance',
        method: 'get_attendance_id',
        args: [],
   }).then (function(res){
   alert(res)
   test = res['id'];
   count_doc = res['count']
   if (count_doc ==1){
   self.do_action({        //action for single record
       type: 'ir.actions.act_window',
       res_model: 'res.model.model',
       name :'Help',
       view_mode: 'form',
        view_type: 'form',
        views: [[false, 'form']],
       target: 'new',
       res_id: test,
   })
   }
   else{
    self.do_action({       //action for multiple records
        name: _("Help"),
        type: 'ir.actions.act_window',
        res_model: 'res.model.model',
        view_mode: 'form,tree',
        view_type: 'form',
        views: [[false, 'list'],[false, 'form']],
        target: 'new',
        domain: [],
    },{on_reverse_breadcrumb: function(){ return self.reload();}})
    }
   });
   }
  });
 var SaleOrderListView = ListView.extend({
   config: _.extend({}, ListView.prototype.config, {
       Controller: TreeButton,
 }),
});
 viewRegistry.add('button_in_tree', SaleOrderListView);
});

How can i open the particular record on click event? I have tried to pass current_target event but doesn't work for me. Also when i am passing target: current it opens the form view in that case.

Do am I missing something? Can anyone suggest me a path to solve this?

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
úno 24
1339
1
pro 22
4218
0
bře 24
1244
1
úno 24
1915
2
led 24
2485