mirror of https://github.com/OCA/web.git
[ADD] Delete all button
parent
7fa82a1a86
commit
618a67ea29
|
@ -12,6 +12,9 @@
|
|||
'data': [
|
||||
'templates/assets.xml'
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/web_x2many_delete_all.xml'
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
|
|
|
@ -1,15 +1,26 @@
|
|||
odoo.define('web_x2many_delete_all', function (require) {
|
||||
"use strict";
|
||||
var core = require('web.core');
|
||||
var _t = core._t;
|
||||
|
||||
var core = require('web.core'),
|
||||
_t = core._t;
|
||||
|
||||
var X2ManyListDeleteAllMixin = {
|
||||
events: {
|
||||
'click th.o_list_record_delete': 'btn_delete_all_clicked'
|
||||
},
|
||||
start: function() {
|
||||
return this._super.apply(this, arguments);
|
||||
reload_current_view: function() {
|
||||
var res = this._super.apply(this, arguments);
|
||||
var self = this;
|
||||
res.then(function() {
|
||||
self.toggle_btn_delete_all();
|
||||
});
|
||||
return res
|
||||
},
|
||||
toggle_btn_delete_all: function() {
|
||||
if(this.get('effective_readonly')) {
|
||||
this.$('th.o_list_record_delete > .fa-trash-o').addClass('hidden');
|
||||
} else {
|
||||
this.$('th.o_list_record_delete > .fa-trash-o').removeClass('hidden');
|
||||
}
|
||||
},
|
||||
btn_delete_all_clicked: function() {
|
||||
if(!this.get('effective_readonly')) {
|
||||
|
@ -21,9 +32,6 @@ odoo.define('web_x2many_delete_all', function (require) {
|
|||
}
|
||||
}
|
||||
|
||||
var many2many = core.form_widget_registry.get('many2many');
|
||||
var one2many = core.form_widget_registry.get('one2many');
|
||||
|
||||
many2many.include(X2ManyListDeleteAllMixin);
|
||||
one2many.include(X2ManyListDeleteAllMixin);
|
||||
core.form_widget_registry.get('many2many').include(X2ManyListDeleteAllMixin);
|
||||
core.form_widget_registry.get('one2many').include(X2ManyListDeleteAllMixin);
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates>
|
||||
<t t-extend="ListView">
|
||||
<t t-jquery=".o_list_record_delete" t-operation="inner">
|
||||
<span class="fa fa-trash-o hidden"/>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
Loading…
Reference in New Issue