This question has been flagged
2 Replies
5279 Views

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');
Avatar
Discard
Best Answer

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

});

Avatar
Discard

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

Best Answer

deprecated on 11

var Model = require('web.Model');
Avatar
Discard