I'm trying to do a widget to attach to the sysTrayMenu, I need to know on the on_click event, the current model of the view. I know that I can get it from the current browser url, but I wanted to know if is there a cleaner way to get it from the odoo js api.
For example if the user is in New quotation menu, I need to get sale.order
odoo.define('xx.systray', function (require) {
"use strict";
var config = require('web.config');
var SystrayMenu = require('web.SystrayMenu');
var Widget = require('web.Widget');
var ajax = require('web.ajax');
var xxMenu = Widget.extend({
template:'solvo-support.helpMenu',
events: {
"click": "on_click",
},
on_click: function () {
//HERE I NEED TO GET THE CURRENT MODEL
},
});
SystrayMenu.Items.push(xxMenu);
});
this.view.model
is an option if view exists in your context. If not, try withthis.field_manager.datarecord
. It has a lot of attributes of the current record, where you'll probably find the current model. Even just inthis.field_manager
you may find it. – forvas