Skip to Content
Menu
This question has been flagged
1 Reply
5038 Views

Hi,

I added a button in the systray in odoo 12, now i want to call a wizard while click on the button

how can i do that

in  .xml

<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="my_systray">
<li class="themes_selector_li">
<label class="switch" style="margin-bottom:0px;">
<div class="systray_click">
<i class="fa fa-bolt"/>
</div>
</label>
</li>
</t>
</templates>
in .js
odoo.define('top_bar_button.systray_button', function (require) {
"use strict";

var core = require('web.core');
var SystrayMenu = require('web.SystrayMenu');
var Widget = require('web.Widget');
var QWeb = core.qweb;
var ajax = require('web.ajax');

var MySystrayWidget = Widget.extend({
template: 'my_systray'
});
SystrayMenu.Items.push(MySystrayWidget);
});


Avatar
Discard
Best Answer
Hi,
It can be done by adding an event to the systray button.
For example, you can use the below code in .js
odoo.define('top_bar_button.systray_button', function (require) {
   "use strict";

   var core = require('web.core');
   var SystrayMenu = require('web.SystrayMenu');
   var Widget = require('web.Widget');
   var QWeb = core.qweb;
   var ajax = require('web.ajax');

var MySystrayWidget = Widget.extend({
   template: 'my_systray',
   events: {
       "click .systray_click": 'button_click'
   },

   button_click: function (e) {
       var self = this;
       e.preventDefault();
       self.do_action({
           name: 'The name of wizard',
           type: 'ir.actions.act_window',
           res_model: 'model of wizard',
           view_type: 'form',
           view_mode: 'tree,form',
           view_id: 'view id of wizard',
           views: [[false, 'list'], [false, 'form']],
           target: 'new'
       }, {
           on_reverse_breadcrumb: function () {
               self.update_control_panel({clear: true, hidden: true});
           }
       });
   }
});
SystrayMenu.Items.push(MySystrayWidget);
});
Avatar
Discard
Related Posts Replies Views Activity
1
Apr 23
18801
1
Jun 22
1673
0
Dec 21
2022
3
Sep 20
5401
0
Aug 16
576