【发布时间】:2017-08-04 09:26:32
【问题描述】:
我必须在 OdooV8 的 One2Many 记录中做一个类似 Add an Item 的功能链接。这是我的 JavaScript 代码:
openerp.my_module = function (instance) {
instance.web.form.One2ManyList.include({
pad_table_to: function (count){
var self = this;
var res = this._super(count);
this.$current.find('.oe_form_field_one2many_list_row_add').append(
$('<a>', {href: '#'}).text(_t(" Add in Configuration"))
.mousedown(function () {
if (self.view.editor.is_editing()) {
self.view.__ignore_blur = true;
}
})
.click(function (e) {
e.preventDefault();
e.stopPropagation();
if (self.view.editor.form.__blur_timeout) {
clearTimeout(self.view.editor.form.__blur_timeout);
self.view.editor.form.__blur_timeout = false;
}
self.view.ensure_saved().done(function () {
//run your js code here
});
})
);
}
})
};
这是采购订单行中的结果:
现在我的问题是:
- 我只想将链接放在特定的 One2Many 对象中,因为它出现在所有 One2Many 视图中。例如,仅在采购订单行中。
- 我想调用一个python函数。一旦点击Add in Configuration,它应该调用一个返回弹出表单的函数。如何 在 JavaScript 中执行此操作?
我仍然不熟悉 JavaScript,有人帮助我完成第一部分。如果您知道如何执行此操作,请帮助我。谢谢。
【问题讨论】:
标签: javascript function openerp odoo-8