我无法在Odoo9中添加新动作
openerp.pr_finance = function(instance, local) {
var _t = instance.web._t, _lt = instance.web._lt;
var QWeb = instance.web.qweb;
var Widget = instance.web.Widget;
var core = instance.web.core;
var data = instance.web.data;
var session = instance.web.session;
var utils = instance.web.utils;
var Model = instance.web.Model;
var ControlPanelMixin = instance.web.ControlPanelMixin;
instance.web.ListView.include({
init: function() {
//console.log('JS loaded');
this._super.apply(this, arguments);
},
render_buttons: function(data) {
console.log('JS loaded load_list');
console.log(data);
this._super(data);
if (this.$buttons) {
this.$buttons.find('.oe_my_button').click(this.proxy('do_import_file_csv_ya_tz')) ;
}
},
do_import_file_csv_ya_tz: function () {
console.log('123123123123123123 ooops....');
this.do_action(
{
name: _t("IMPORT MY FILE"),
type: "ir.actions.client",
tag: 'import_csv',
params: {}
}
);
}
});
var import_csv_yandex = Widget.extend({
template: 'ImportViewYaTC',
start: function () {
console.log("ImportViewYandexTC page loaded");
},
});
var DataImport = Widget.extend(ControlPanelMixin, {
template: 'ImportView',
init: function(parent, action) {
console.log("init ImportView");
this._super.apply(this, arguments);
action.display_name = _t('Import a File');
},
start: function () {
console.log("ImportView page loaded");
},
});
console.log("core.action_registry.add");
try {
instance.web.core.action_registry.add('import_csv', DataImport);
} catch (err) {
console.log(err);
}
console.log("core.action_registry.add - OK!");
}
我在这里收到错误:
instance.web.core.action_registry.add('import_csv', DataImport);
错误:
TypeError:instance.web.core未定义堆栈跟踪: openerp.pr_finance@http//localhost:8069 /网络/内容/ 2798-e13ba1c / web.assets_backend.js:4579:1276 start_modules @ HTTP //本地主机:8069 /网页/内容/ 2798-e13ba1c / web.assets_backend.js:3235:1 @的.init访问http //本地主机:8069 /网络/内容/ 2798-e13ba1c / web.assets_backend.js:3229:3951 OdooClass.extend / Class.include /
为什么这个变量未定义?
答案 0 :(得分:0)
您需要使用require
来获取env的变量:ie。
odoo.define('yourmodulename.pr_finance', function (require) {
"use strict";
var core = require('web.core');
});
在odoo中了解继承的好地方是github.com/oca/web回购。