javascript - Is it possible to get the xml_id from JS code in Odoo? -


i trying specific menuitem , store in variable in javascript:

var menus = new openerp.web.model('ir.ui.menu'); 

now, can apply filter menus menuitem, example, name, thing there lot of menuitems same name. think attribute identifies menuitem , differences other xml id.

but not know how javascript code. there built function obtain it? how can manage purpose?

well, have found workaround. may there better solution, in case, please, post it.

in database, there table named ir_model_data. table stores xml ids, under column name. columns model , res_id indicate model xml id record stored , id. there column named module, can used put before xml id extracted (column name), module_name.xml_id notation.

for example:

i have record ir.ui.menu model id 303, , want xml id javascript:

var menus = new openerp.web.model('ir.model.data'); menus.query(['name']).filter(['&', ['model', '=', 'ir.ui.menu'], ['res_id', '=', 303]]).all().then(function(ir_model_datas) {    (i in ir_model_datas) {       console.log(ir_model_datas[i].name);    } }); 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -