From 618a67ea293f138302e4c27503a05cff6952a07f Mon Sep 17 00:00:00 2001 From: tarteo Date: Fri, 11 Nov 2016 00:43:31 +0100 Subject: [PATCH] [ADD] Delete all button --- web_x2many_delete_all/__manifest__.py | 3 ++ .../static/src/js/web_x2many_delete_all.js | 28 ++++++++++++------- .../static/src/xml/web_x2many_delete_all.xml | 8 ++++++ 3 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml diff --git a/web_x2many_delete_all/__manifest__.py b/web_x2many_delete_all/__manifest__.py index cd41dbef..f9adab11 100644 --- a/web_x2many_delete_all/__manifest__.py +++ b/web_x2many_delete_all/__manifest__.py @@ -12,6 +12,9 @@ 'data': [ 'templates/assets.xml' ], + 'qweb': [ + 'static/src/xml/web_x2many_delete_all.xml' + ], 'installable': True, 'application': False, } diff --git a/web_x2many_delete_all/static/src/js/web_x2many_delete_all.js b/web_x2many_delete_all/static/src/js/web_x2many_delete_all.js index 571d1f47..1ac83f54 100644 --- a/web_x2many_delete_all/static/src/js/web_x2many_delete_all.js +++ b/web_x2many_delete_all/static/src/js/web_x2many_delete_all.js @@ -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); }); \ No newline at end of file diff --git a/web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml b/web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml new file mode 100644 index 00000000..20c43156 --- /dev/null +++ b/web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml @@ -0,0 +1,8 @@ + + + + + + +