تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
6386 أدوات العرض

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');
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
Current model name تم الحل
1
يوليو 22
9013
1
مايو 21
3157
2
مايو 20
9757
1
يناير 20
5006
0
مارس 19
3369