Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6143 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
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);
});
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 23
21548
1
thg 12 24
1726
1
thg 6 22
2793
0
thg 12 21
2806
3
thg 9 20
6566