[ADD] Delete all button

pull/477/head
tarteo 2016-11-11 00:43:31 +01:00
parent 7fa82a1a86
commit 618a67ea29
3 changed files with 29 additions and 10 deletions

View File

@ -12,6 +12,9 @@
'data': [ 'data': [
'templates/assets.xml' 'templates/assets.xml'
], ],
'qweb': [
'static/src/xml/web_x2many_delete_all.xml'
],
'installable': True, 'installable': True,
'application': False, 'application': False,
} }

View File

@ -1,15 +1,26 @@
odoo.define('web_x2many_delete_all', function (require) { odoo.define('web_x2many_delete_all', function (require) {
"use strict"; "use strict";
var core = require('web.core'); var core = require('web.core'),
var _t = core._t; _t = core._t;
var X2ManyListDeleteAllMixin = { var X2ManyListDeleteAllMixin = {
events: { events: {
'click th.o_list_record_delete': 'btn_delete_all_clicked' 'click th.o_list_record_delete': 'btn_delete_all_clicked'
}, },
start: function() { reload_current_view: function() {
return this._super.apply(this, arguments); 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() { btn_delete_all_clicked: function() {
if(!this.get('effective_readonly')) { 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'); core.form_widget_registry.get('many2many').include(X2ManyListDeleteAllMixin);
var one2many = core.form_widget_registry.get('one2many'); core.form_widget_registry.get('one2many').include(X2ManyListDeleteAllMixin);
many2many.include(X2ManyListDeleteAllMixin);
one2many.include(X2ManyListDeleteAllMixin);
}); });

View File

@ -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>