From 6fe337929d5529619e3c8b522c86d6472daf6d78 Mon Sep 17 00:00:00 2001 From: Tom Blauwendraat Date: Mon, 1 Oct 2018 17:17:34 +0200 Subject: [PATCH] [FIX] Fixes in code style, readme, file naming etc. --- web_tree_date_search/README.rst | 50 +++-- web_tree_date_search/__init__.py | 19 +- web_tree_date_search/__openerp__.py | 27 +-- .../static/description/icon.png | Bin 0 -> 4010 bytes .../static/src/css/web_tree_date_search.css | 20 ++ web_tree_date_search/static/src/js/search.js | 178 ---------------- .../static/src/js/web_tree_date_search.js | 196 ++++++++++++++++++ .../static/src/xml/search.xml | 19 -- .../static/src/xml/web_tree_date_search.xml | 19 ++ web_tree_date_search/views/assets_backend.xml | 6 +- 10 files changed, 281 insertions(+), 253 deletions(-) create mode 100644 web_tree_date_search/static/description/icon.png create mode 100644 web_tree_date_search/static/src/css/web_tree_date_search.css delete mode 100644 web_tree_date_search/static/src/js/search.js create mode 100644 web_tree_date_search/static/src/js/web_tree_date_search.js delete mode 100644 web_tree_date_search/static/src/xml/search.xml create mode 100644 web_tree_date_search/static/src/xml/web_tree_date_search.xml diff --git a/web_tree_date_search/README.rst b/web_tree_date_search/README.rst index 4565096c..b8a1f806 100644 --- a/web_tree_date_search/README.rst +++ b/web_tree_date_search/README.rst @@ -1,35 +1,57 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 -Tree Date Search -============================== +===================== +Tree View Date Search +===================== -This module allow you to easily add dates range search fields on top of List View rows. +This module allow you to easily add date range search fields to tree views. +These date fields can be used in combination with the Search window. -These dates fields can be used in combination with the Search window. +Usage +===== -How to do ? +Add a new 'dates_filter' key and a list of field names in the action context: + +.. code:: python + + {'dates_filter': ['start']} -Add a new 'dates_filter' key and a list of fields name in the action context: -{'dates_filter': ['start']} or several dates: -{'dates_filter': ['start','stop',..]} -.. image:: web_tree_date_search/static/src/img/demo.png -.. image:: web_tree_date_search/static/src/img/demo1.png +.. code:: python + + {'dates_filter': ['start','stop',..]} + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and +welcomed feedback `here `__. Credits ======= -Author +Images ------ + +* PICOL Icon Generator `here `__. + +Contributors +------------ + +* Tom Blauwendraat * Thomas Fossoul, Noviat Maintainer ---------- -.. image:: http://odoo-community.org/logo.png + +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. diff --git a/web_tree_date_search/__init__.py b/web_tree_date_search/__init__.py index 4cace334..40a96afc 100644 --- a/web_tree_date_search/__init__.py +++ b/web_tree_date_search/__init__.py @@ -1,18 +1 @@ -############################################################################## -# -# Copyright (c) 2015 Noviat nv/sa (www.noviat.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- diff --git a/web_tree_date_search/__openerp__.py b/web_tree_date_search/__openerp__.py index 1d31645f..95afc4f2 100644 --- a/web_tree_date_search/__openerp__.py +++ b/web_tree_date_search/__openerp__.py @@ -1,28 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (c) 2015 Noviat nv/sa (www.noviat.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# Copyright 2015 Noviat nv/sa (http://www.noviat.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Tree dates search', - 'version': '8.0.3.0.1', + 'version': '8.0.1.0.0', 'author': 'Noviat, Odoo Community Association (OCA)', - 'website': 'http://www.noviat.com', + 'website': 'https://github.com/OCA/web', 'license': 'AGPL-3', 'category': 'Web', 'depends': [ @@ -32,7 +15,7 @@ 'views/assets_backend.xml', ], 'qweb': [ - 'static/src/xml/*.xml', + 'static/src/xml/web_tree_date_search.xml', ], 'demo': [ 'demo/demo.xml', diff --git a/web_tree_date_search/static/description/icon.png b/web_tree_date_search/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..09bd574a3f95c204b0d256a573b7b1f83f26f65d GIT binary patch literal 4010 zcmZu!dpJ~G7vD2x+=ZlZi=hcqA(xcgg>i}+mzsnq@={KsBqF2xJ&xoW<5EqMN*qGt zlB6QiTjEqyuBm2n$=&&;zUTR#x3_OU&)$3O^Q^Uhzx7*d|8Y(;H!x%*RU`obGLVzK zn{a3UoZ_Ow^`X`FX8?!*rn85G@QDAK_^%BYp75Uo!!Q&@5d?u@7=j=gjfMe$0)PMj z0{{U)6Gr{<3Bv%20t5jt3?K;5{+|;DFchE&Kwtnv0HO(R`XlU5cpODB1VLdKfgqSh z!x037VHAQ8p$)?r1ffC$f-vDKq>5uGh9W2eBQOL*G>C@cD1sp{3PT7)gJ}qkz!(gn z5DlThI1FJz4;q9+v|sTU_AfLDMgIv1Bgp?Sh5Gy#R>=6VLU$aX7(h?}Bf_>tae!b#3P1?-YqTsSk^qq23EA6v9PIq+gN4%=@|Le&wmEGr zS#5(PdcM9xSxefkRx4E{kcc7U^}aQcH6n5igo83)j#N3JCE8npm)z>xY~gXO(xc#W z5wCqe%h5R~GO)s2XT)P$fzeI&=TR3>O%m(|afCZWYH2&2-32BT**d2dw#^ub~H-P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dbp8Ntser(^-nNd`WnQwF3h<; ylKEt=wWJL$lOwDMU*`%(7C8+qA{8HI;bQy4r3Mrf!`}b=^MD*S*caLP9r+KtHF_ri literal 0 HcmV?d00001 diff --git a/web_tree_date_search/static/src/css/web_tree_date_search.css b/web_tree_date_search/static/src/css/web_tree_date_search.css new file mode 100644 index 00000000..d607c65c --- /dev/null +++ b/web_tree_date_search/static/src/css/web_tree_date_search.css @@ -0,0 +1,20 @@ +div.web_tree_date_search_toolbar { + margin-bottom:0px; +} + +div.web_tree_date_search_field { + min-width: 208px; margin-left:4px; +} + +div.web_tree_date_search_field div.oe_form { + margin-right:3px; display: inline; +} + +input.web_tree_date_search_input { + height: 23px; +} + +input.web_tree_date_search_input_date { + width: 105px; +} + diff --git a/web_tree_date_search/static/src/js/search.js b/web_tree_date_search/static/src/js/search.js deleted file mode 100644 index 55157905..00000000 --- a/web_tree_date_search/static/src/js/search.js +++ /dev/null @@ -1,178 +0,0 @@ -// @@@ web_tree_date_search custom JS @@@ -// ############################################################################# -// -// Copyright (c) 2015 Noviat nv/sa (www.noviat.com) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// -// ############################################################################# - - -openerp.web_tree_date_search = function(instance) { - var _t = instance.web._t, - _lt = instance.web._lt; - var QWeb = instance.web.qweb; - - instance.web.ListView.include({ - init: function(parent, dataset, view_id, options) { - this._super.apply(this, arguments); - if ("dates_filter" in dataset.context){ - this.dates_filter = dataset.context["dates_filter"]; - this.current_date_from = []; - this.current_date_to = []; - } - this.tree_date_search_loaded = false; - }, - do_load_state: function(state, warm) { - var ui_toolbar_loc = $('.ui-toolbar:last'); - if (this.dates_filter && this.dates_filter.length > 0){ - ui_toolbar_loc.show(); - } - else{ - if (ui_toolbar_loc.children().length == 0) - ui_toolbar_loc.hide(); - } - return this._super.apply(this, arguments); - }, - load_list: function(data) { - var self = this; - var tmp = this._super.apply(this, arguments); - if (!this.tree_date_search_loaded){ - this.date_field_data = []; - for (i in this.dates_filter){ - var date_field = this.dates_filter[i]; - for (col in this.columns){ - if (this.columns[col].name == date_field){ - this.date_field_data[date_field] = [] - this.date_field_data[date_field][0] = this.columns[col].string; - this.date_field_data[date_field][1] = this.columns[col].type; - break; - } - } - } - if (this.dates_filter && this.dates_filter.length > 0){ - this.$el.parent().prepend(QWeb.render('TreeDateSearch', {widget: this})); - var ui_toolbar_loc = $('.ui-toolbar:last'); - ui_toolbar_loc.show(); - for (i in this.dates_filter){ - var date_field = this.dates_filter[i]; - var date_string = this.date_field_data[date_field][0] - var date_type = this.date_field_data[date_field][1] - - self.columns - var date_div = QWeb.render('TreeDateSearchField', {'field_name': date_string}); - var toolbar_height = ui_toolbar_loc.height(); - - ui_toolbar_loc.append(date_div); - $('div.oe_form_dropdown_section:last span:eq(0)').addClass('oe_date_filter_from_' + date_field); - $('div.oe_form_dropdown_section:last span:eq(1)').addClass('oe_date_filter_to_' + date_field); - - this.value = new (instance.web.search.custom_filters.get_object(date_type)) - (this, {"selectable":true, - "name":"oe_date_filter_from_" + date_field, - "type": date_type, - "string":date_string}); - var value_loc = $('.oe_date_filter_from_' + date_field + ':last').show().empty(); - this.value.appendTo(value_loc); - - this.value = new (instance.web.search.custom_filters.get_object(date_type)) - (this, {"selectable":true, - "name":"oe_date_filter_to_" + date_field, - "type": date_type, - "string":date_string}); - var value_loc = $('.oe_date_filter_to_' + date_field + ':last').show().empty(); - this.value.appendTo(value_loc); - - var oe_date_filter_from = $('.oe_date_filter_from_' + date_field + ':last .oe_datepicker_master'); - var oe_date_filter_to = $('.oe_date_filter_to_' + date_field + ':last .oe_datepicker_master'); - if (date_type == 'date'){ - oe_date_filter_from.css("width", "105px"); - oe_date_filter_to.css("width", "105px"); - } - oe_date_filter_from.css("height", "23px"); - oe_date_filter_to.css("height", "23px"); - // In 2 line to fit with account move line tree view - if (toolbar_height < 40){ - var $elem1 = oe_date_filter_from.parent().parent().parent().parent().parent(); - var $elem = $elem1.find("h4"); - $elem.css("display", "inline"); - } - oe_date_filter_from.attr("placeholder", _t("From")); - oe_date_filter_to.attr("placeholder", _t("To")); - - // on_change - oe_date_filter_from.change(function() { - var elem = this.parentElement.parentElement.parentElement.className; - var res = elem.split("oe_date_filter_from_"); - self.current_date_from[res[1]] = this.value === '' ? null : this.value; - if (self.current_date_from[res[1]]){ - self.current_date_from[res[1]] = instance.web.parse_value( - self.current_date_from[res[1]], {"widget": date_type}); - } - self.do_search(self.last_domain, self.last_context, self.last_group_by); - }); - oe_date_filter_to.change(function() { - var elem = this.parentElement.parentElement.parentElement.className; - var res = elem.split("oe_date_filter_to_"); - self.current_date_to[res[1]] = this.value === '' ? null : this.value; - if (self.current_date_to[res[1]]){ - self.current_date_to[res[1]] = instance.web.parse_value( - self.current_date_to[res[1]], {"widget": date_type}); - } - self.do_search(self.last_domain, self.last_context, self.last_group_by); - }); - this.on('edit:after', this, function () { - oe_date_filter_from.attr('disabled', 'disabled'); - oe_date_filter_to.attr('disabled', 'disabled'); - }); - this.on('save:after cancel:after', this, function () { - oe_date_filter_from.removeAttr('disabled'); - oe_date_filter_to.removeAttr('disabled'); - }); - } - } - else{ - // Only hide current if it's empty - // Work from tree view to tree view with or withouth date_filters - // Work from tree view to wizard with or withouth date_filters - var ui_toolbar_loc = $('.ui-toolbar:last'); - if (ui_toolbar_loc.children().length == 0) - ui_toolbar_loc.hide(); - } - this.tree_date_search_loaded = true; - } - return tmp; - }, - do_search: function(domain, context, group_by) { - this.last_domain = domain; - this.last_context = context; - this.last_group_by = group_by; - domain = this.get_dates_filter_domain(domain); - return this._super(domain, context, group_by); - }, - get_dates_filter_domain: function(last_domain) { - var domain = []; - for (from in this.current_date_from){ - if (this.current_date_from[from]) - domain.push([from, '>=', this.current_date_from[from]]); - } - for (to in this.current_date_to){ - if (this.current_date_to[to]) - domain.push([to, '<=', this.current_date_to[to]]); - } - return new instance.web.CompoundDomain(last_domain, domain); - }, - }); - -}; diff --git a/web_tree_date_search/static/src/js/web_tree_date_search.js b/web_tree_date_search/static/src/js/web_tree_date_search.js new file mode 100644 index 00000000..1bf45386 --- /dev/null +++ b/web_tree_date_search/static/src/js/web_tree_date_search.js @@ -0,0 +1,196 @@ +// Copyright (c) 2015 Noviat nv/sa (www.noviat.com) + +openerp.web_tree_date_search = function(instance) { + var _t = instance.web._t, + _lt = instance.web._lt; + var QWeb = instance.web.qweb; + + instance.web.ListView.include({ + init: function(parent, dataset, view_id, options) { + this._super.apply(this, arguments); + if ("dates_filter" in dataset.context){ + this.dates_filter = dataset.context["dates_filter"]; + this.current_date_from = []; + this.current_date_to = []; + } + this.tree_date_search_loaded = false; + }, + do_load_state: function(state, warm) { + var ui_toolbar_loc = $('.ui-toolbar:last'); + if (this.dates_filter && this.dates_filter.length > 0){ + ui_toolbar_loc.show(); + } + else{ + if (ui_toolbar_loc.children().length == 0) + ui_toolbar_loc.hide(); + } + return this._super.apply(this, arguments); + }, + load_list: function(data) { + var self = this; + var ret = this._super.apply(this, arguments); + + // dont run if already loaded + if (this.tree_date_search_loaded) + return ret; + + this.date_field_data = []; + for (i in this.dates_filter) { + var date_field = this.dates_filter[i]; + for (col in this.columns){ + if (this.columns[col].name == date_field){ + this.date_field_data[date_field] = [ + this.columns[col].string, + this.columns[col].type + ] + break; + } + } + } + + var custom_filters = instance.web.search.custom_filters; + var INPUT_SELECTOR = ' .oe_datepicker_master'; + if (this.dates_filter && this.dates_filter.length > 0) { + this.$el.parent().prepend(QWeb.render( + 'web_tree_date_search_toolbar', {widget: this})); + var ui_toolbar_loc = $('.ui-toolbar:last'); + ui_toolbar_loc.show(); + for (i in this.dates_filter) { + var date_field = this.dates_filter[i]; + var date_string = this.date_field_data[date_field][0]; + var date_type = this.date_field_data[date_field][1]; + + // add search form to toolbar + var date_div = QWeb.render('web_tree_date_search_field', { + 'field_name': date_string + }); + var toolbar_height = ui_toolbar_loc.height(); + ui_toolbar_loc.append(date_div); + + // assign classes to 'from' and 'to' spans + var from_class = 'oe_date_filter_from_' + date_field, + to_class = 'oe_date_filter_to_' + date_field, + from_selector = '.' + from_class + ':last', + to_selector = '.' + to_class + ':last', + spans = $('div.oe_form_dropdown_section:last span'); + spans.eq(0).addClass(from_class); + spans.eq(1).addClass(to_class); + + // add date input elements to each + function add_input_element(_class, selector) { + var value = new (custom_filters.get_object(date_type))( + this, { + "selectable": true, + "name": _class, + "type": date_type, + "string": date_string + } + ); + var value_loc = $(selector).show().empty(); + value.appendTo(value_loc); + return value; + } + this.value = add_input_element(from_class, from_selector); + this.value = add_input_element(to_class, to_selector); + + // sizing of the input elements + var input_from = $(from_selector + INPUT_SELECTOR); + var input_to = $(to_selector + INPUT_SELECTOR); + if (date_type == 'date') { + input_from.addClass('web_tree_date_search_input_date'); + input_to.addClass('web_tree_date_search_input_date'); + } + input_from.addClass('web_tree_date_search_input'); + input_to.addClass('web_tree_date_search_input'); + // In 2 line to fit with account move line tree view + if (toolbar_height < 40) { + var $elem1 = input_from.parent() + .parent().parent().parent().parent(); + var $elem = $elem1.find("h4"); + $elem.css("display", "inline"); + } + input_from.attr("placeholder", _t("From")); + input_to.attr("placeholder", _t("To")); + + // on_change functions + input_from.change(function() { + var elem = this.parentElement. + parentElement.parentElement.className; + var res = elem.split("oe_date_filter_from_"); + self.current_date_from[res[1]] = + this.value === '' ? null : this.value; + if (self.current_date_from[res[1]]){ + self.current_date_from[res[1]] = + instance.web.parse_value( + self.current_date_from[res[1]], + {"widget": date_type} + ); + } + self.do_search( + self.last_domain, + self.last_context, + self.last_group_by + ); + }); + input_to.change(function() { + var elem = this.parentElement. + parentElement.parentElement.className; + var res = elem.split("oe_date_filter_to_"); + self.current_date_to[res[1]] = + this.value === '' ? null : this.value; + if (self.current_date_to[res[1]]){ + self.current_date_to[res[1]] = + instance.web.parse_value( + self.current_date_to[res[1]], + {"widget": date_type} + ); + } + self.do_search( + self.last_domain, + self.last_context, + self.last_group_by + ); + }); + this.on('edit:after', this, function() { + input_from.attr('disabled', 'disabled'); + input_to.attr('disabled', 'disabled'); + }); + this.on('save:after cancel:after', this, function() { + input_from.removeAttr('disabled'); + input_to.removeAttr('disabled'); + }); + } + } + else { + // Only hide current if it's empty + // Work from tree view to tree view with or without date_filters + // Work from tree view to wizard with or without date_filters + var ui_toolbar_loc = $('.ui-toolbar:last'); + if (ui_toolbar_loc.children().length == 0) + ui_toolbar_loc.hide(); + } + this.tree_date_search_loaded = true; + return ret; + }, + do_search: function(domain, context, group_by) { + this.last_domain = domain; + this.last_context = context; + this.last_group_by = group_by; + domain = this.get_dates_filter_domain(domain); + return this._super(domain, context, group_by); + }, + get_dates_filter_domain: function(last_domain) { + var domain = []; + for (from in this.current_date_from){ + if (this.current_date_from[from]) + domain.push([from, '>=', this.current_date_from[from]]); + } + for (to in this.current_date_to){ + if (this.current_date_to[to]) + domain.push([to, '<=', this.current_date_to[to]]); + } + return new instance.web.CompoundDomain(last_domain, domain); + }, + }); + +}; diff --git a/web_tree_date_search/static/src/xml/search.xml b/web_tree_date_search/static/src/xml/search.xml deleted file mode 100644 index 6a34ebb3..00000000 --- a/web_tree_date_search/static/src/xml/search.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - -
-
-
- - -
-

:

-
- -
-
- -
-
-
-
diff --git a/web_tree_date_search/static/src/xml/web_tree_date_search.xml b/web_tree_date_search/static/src/xml/web_tree_date_search.xml new file mode 100644 index 00000000..602dd252 --- /dev/null +++ b/web_tree_date_search/static/src/xml/web_tree_date_search.xml @@ -0,0 +1,19 @@ + + + +
+
+
+ + +
+

:

+
+ +
+
+ +
+
+
+
diff --git a/web_tree_date_search/views/assets_backend.xml b/web_tree_date_search/views/assets_backend.xml index c562953b..1f6a7479 100644 --- a/web_tree_date_search/views/assets_backend.xml +++ b/web_tree_date_search/views/assets_backend.xml @@ -3,8 +3,10 @@