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

I'm trying to inherit web.Model in a JS file to call a function in a Python model but it keeps returning an error.
The error is "missing dependecies" on "web.Model", and I can see it only in the console of the browser.


odoo.define('na_MTC.screens', function (require){
"use strict";
var point_of_sale = require('point_of_sale.screens');
var core = require('web.ajax');
var Model = require('web.Model');
形象
丢弃
最佳答案

try to use this :

var rpc = require('web.rpc');

istead of:

var Model = require('web.model');

and use query to call your method:

rpc.query({

     model: //your model,

     method: //your method,

    args: [{

        'arg1': value1,

    }]

}).then(function (result) {

            // your code

});

形象
丢弃

For me work like this on Odoo 13 CE:

//var Model = require('web.model');
/*
new Model('ir.config_parameter').call('search_read', [[['key', '=', 'app_show_debug']], ['value']]).then(function (show) {
if (show.length >= 1 && (show[0]['value'] == "False")) {
$('[data-menu="debug"]').parent().hide();
$('[data-menu="debugassets"]').parent().hide();
$('[data-menu="quitdebug"]').parent().hide();
}
});
*/
var rpc = require('web.rpc');
rpc.query({
model: 'ir.config_parameter', //your model
method: 'search_read', //your method
// args: [{'arg1': value1,}]
args: [[['key', '=', 'app_show_debug']], ['value']],
limit: 1,
}).then(function (show) {
// your code
if (show.length >= 1 && (show[0]['value'] == "False")) {
$('[data-menu="debug"]').parent().hide();
$('[data-menu="debugassets"]').parent().hide();
$('[data-menu="quitdebug"]').parent().hide();
}
});

最佳答案

deprecated on 11

var Model = require('web.Model');
形象
丢弃
相关帖文 回复 查看 活动
1
7月 22
8747
1
5月 21
2872
2
5月 20
9446
1
1月 20
4676
0
3月 19
3107