odoo 12 中的 JavaScript

标签 javascript button odoo

我想在odoo中创建一个新的js文件。

此文件适用于在 TreeView 中创建的按钮。此 TreeView 以 XML 文件形式提供。为此,我在 static 文件夹中创建了一个 js 文件。但我不知道这个按钮如何调用js文件的函数。 什么是web.core?如果我想访问odoo中的模型如何访问这个模型?

最佳答案

您可以通过在js文件中的事件中定义来调用函数。 例如,我在这里访问chatterbox

odoo.define('yourmodule.js script', function (require) {
"use strict";

var attchment_box = require('mail.AttachmentBox');
var core = require('web.core');

var QWeb = core.qweb;

attchment_box.include({
events: _.extend({}, attchment_box.prototype.events, {
    "click .your button class or # button id": "your method name",

}),
init: function () {

    this._super.apply(this, arguments);

},
start: function() {

    this._super.apply(this, arguments);
},


your method: function (ev) {
    //Your button code
 },
});

});

像这样,您可以扩展 TreeView 并在js文件中添加按钮代码。

关于odoo 12 中的 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59559272/

相关文章:

javascript - 如何使用 JayData 为 indexedDB 中的表创建索引

javascript - 如何使用 JavaScript 代码计算禁用按钮的时间?

xml - 无法翻译 Odoo 10 中 Qweb 条件内的术语。该怎么做?

javascript - 从行数据创建层次结构

javascript - 从js文件发送POST请求到php文件

java - 向另一个类显示文本

android - 如何在android中设置按钮样式

python - Odoo 错误,伙伴无法关注同一个对象两次

python - 奥杜 10 : How to approve a record of odoo from a button in email?

javascript - 循环遍历一个 JSON 对象并根据指定的值返回一个键