跳至内容
菜单
此问题已终结
1 回复
6141 查看

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);
});


形象
丢弃
最佳答案
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);
});
形象
丢弃
相关帖文 回复 查看 活动
1
4月 23
21548
1
12月 24
1725
1
6月 22
2793
0
12月 21
2803
3
9月 20
6564