Browse Source

[ADD] Delete all button

pull/477/head
tarteo 8 years ago
parent
commit
618a67ea29
  1. 3
      web_x2many_delete_all/__manifest__.py
  2. 28
      web_x2many_delete_all/static/src/js/web_x2many_delete_all.js
  3. 8
      web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml

3
web_x2many_delete_all/__manifest__.py

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

28
web_x2many_delete_all/static/src/js/web_x2many_delete_all.js

@ -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 _t = core._t;
var core = require('web.core'),
_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() {
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() { 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');
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);
}); });

8
web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml

@ -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…
Cancel
Save