Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
6129 Vizualizări

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


Imagine profil
Abandonează
Cel mai bun răspuns
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);
});
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
apr. 23
21544
1
dec. 24
1714
1
iun. 22
2789
0
dec. 21
2799
3
sept. 20
6547