Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Odoo9JavaScript调用python方法_Javascript_Python_Odoo 9 - Fatal编程技术网

如何从Odoo9JavaScript调用python方法

如何从Odoo9JavaScript调用python方法,javascript,python,odoo-9,Javascript,Python,Odoo 9,我有一段代码可以在javascript中调用python方法,但是代码不起作用,并且会显示一个错误 error: Some modules could not be started Failed modules: ["group_js.costume"] Debug: Object {group_js.costume: Object} 我的.py文件是 class group_js(osv.osv): _name = "group_js" _description = "G

我有一段代码可以在javascript中调用python方法,但是代码不起作用,并且会显示一个错误

 error: Some modules could not be started 
 Failed modules: ["group_js.costume"] 
 Debug:  Object {group_js.costume: Object}
我的.py文件是

class group_js(osv.osv):
  _name = "group_js"
  _description = "Group JS"
  _columns={
      'js' : fields.text('Javascript',required = True , store=True),
     }
 @api.multi
 def get_record(self):
     return [(i.js) for i in self]
我的.js文件是

odoo.define('group_js.costume', function (instance) {
     new instance.web.Model("group_js").call("get_record",[list_of_record]).then(function(result){
     console.log("hiiii");
   });
});
所以我不知道如何修复,所以请帮助我修复这个错误


感谢在javascript中调用model().call()中的odoo python模型中的方法

例如,考虑py文件中的以下模型

class group_js(models.Model):
   _name = "model.example"
   _description = "Example model"

   def get_record(self):
       return ''
从javascript文件中,您可以将其称为:

new Model("model.example").call("get_record",[args]).then(function(result){ 
    console.log(result);//show in console Hello
});
以下是调用方法的详细信息:

/**
 * Call a method (over RPC) on the bound OpenERP model.
 *
 * @param {String} method name of the method to call
 * @param {Array} [args] positional arguments
 * @param {Object} [kwargs] keyword arguments
 * @param {Object} [options] additional options for the rpc() method
 * @returns {jQuery.Deferred<>} call result
 */
/**
*在绑定的OpenERP模型上调用方法(通过RPC)。
*
*@param{String}方法要调用的方法的名称
*@param{Array}[args]位置参数
*@param{Object}[kwargs]关键字参数
*@param{Object}[options]rpc()方法的其他选项
*@returns{jQuery.Deferred}调用结果
*/

从何处导入模型?