Here is my previous question. Now i created a do_delete
method which extends the original one. I also included this into views.xml
<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>
But the issue i am facing is that. It only works when i enable debug=assets
and i just recently discovered that it doesn't even work with normal debug=1
mode.
Edit
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();
});
}
},
});
});
Edit 2
This my complete xml file which i am including in manifest.
<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>