Openerp 扩展方法不起作用
这是我以前的工作。现在我创建了一个Openerp 扩展方法不起作用,openerp,odoo-view,Openerp,Odoo View,这是我以前的工作。现在我创建了一个do\u delete方法,它扩展了原来的方法。我还将其包含在views.xml 但我面临的问题是。它只在我启用debug=assets时起作用,而我最近发现它甚至不能在正常debug=1模式下工作 编辑 amgl.js function join_name(names) { var str = ""; var step; for (step = 0; step < names.length; step++) { str = str + (st
do\u delete
方法,它扩展了原来的方法。我还将其包含在views.xml
但我面临的问题是。它只在我启用debug=assets
时起作用,而我最近发现它甚至不能在正常debug=1
模式下工作
编辑
amgl.js
function join_name(names) {
var str = "";
var step;
for (step = 0; step < names.length; step++) {
str = str + (step + 1) + '- ' + names[step].full_name + ' \n';
};
return str;
}
odoo.define('amgl.web.ListView', function (require) {
"use strict";
var core = require('web.core');
var _t = core._t;
var Model = require('web.DataModel');
var ListView = require('web.ListView');
var ListViewDeleteExtension = ListView.include({
do_delete: function (ids) {
if (this.model == 'amgl.customer') {
var self = this;
new Model(self.model).call('read', [ids, ['full_name'], this.dataset.get_context()])
.done(function (names) {
var text = _t("Do you really want to remove these records?") + ' \n \n' + join_name(names)
if (!(ids.length && confirm(text))) {
return;
}
return $.when(self.dataset.unlink(ids)).done(function () {
_(ids).each(function (id) {
self.records.remove(self.records.get(id));
});
// Hide the table if there is no more record in the dataset
if (self.display_nocontent_helper()) {
self.no_result();
} else {
if (self.records.length && self.current_min === 1) {
// Reload the list view if we delete all the records of the first page
self.reload();
} else if (self.records.length && self.dataset.size() > 0) {
// Load previous page if the current one is empty
self.pager.previous();
}
// Reload the list view if we are not on the last page
if (self.current_min + self._limit - 1 < self.dataset.size()) {
self.reload();
}
}
self.update_pager(self.dataset);
self.compute_aggregates();
});
});
}
else {
if (!(ids.length && confirm(_t("Do you really want to remove these records?")))) {
return;
}
var self = this;
return $.when(this.dataset.unlink(ids)).done(function () {
_(ids).each(function (id) {
self.records.remove(self.records.get(id));
});
// Hide the table if there is no more record in the dataset
if (self.display_nocontent_helper()) {
self.no_result();
} else {
if (self.records.length && self.current_min === 1) {
// Reload the list view if we delete all the records of the first page
self.reload();
} else if (self.records.length && self.dataset.size() > 0) {
// Load previous page if the current one is empty
self.pager.previous();
}
// Reload the list view if we are not on the last page
if (self.current_min + self._limit - 1 < self.dataset.size()) {
self.reload();
}
}
self.update_pager(self.dataset);
self.compute_aggregates();
});
}
},
});
});
函数连接名称(名称){
var str=“”;
var阶跃;
对于(步长=0;步长0){
//如果当前页面为空,则加载上一页
self.pager.previous();
}
//如果不在最后一页,请重新加载列表视图
if(self.current\u min+self.\u limit-10){
//如果当前页面为空,则加载上一页
self.pager.previous();
}
//如果不在最后一页,请重新加载列表视图
if(self.current\u min+self.\u limit-1
编辑2
这是包含在清单中的完整xml文件
<odoo>
<data>
<template id="assets_backend" name="amgl assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript"
src="/amgl/static/src/js/amgl.js">
</script>
</xpath>
</template>
<template id="assets_backend1"
name="web_duplicate_visibility backend assets"
inherit_id="web.assets_backend">
<xpath expr="."
position="inside">
<script type="text/javascript"
src="/amgl/static/src/js/duplicate_visibility.js">
</script>
</xpath>
</template>
</data>
要使其工作,您必须扩展保存在core.view\u注册表中的类:
函数连接名称(名称){
var str=“”;
var阶跃;
对于(步长=0;步长