diff --git a/web_search_date/README.rst b/web_search_date/README.rst new file mode 100644 index 000000000..660a9dad6 --- /dev/null +++ b/web_search_date/README.rst @@ -0,0 +1,81 @@ +=============== +Web Search Date +=============== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/11.0/web_search_date + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-11-0/web-11-0-web_search_date + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allows to search on dates with before and after directly on the search bar +without the "Extra filters". + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Write the date and the options `before`, `at` and `after` will be added. +You need to write at least the year and the month, for example: 2020-01 for +january 2020. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Creu Blanca + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_search_date/__init__.py b/web_search_date/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/web_search_date/__manifest__.py b/web_search_date/__manifest__.py new file mode 100644 index 000000000..c4d78f9d4 --- /dev/null +++ b/web_search_date/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Web Search Date', + 'summary': """ + Add more options for search on dates""", + 'version': '11.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Creu Blanca,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/web', + 'depends': [ + 'web' + ], + 'data': [ + 'views/web_widget_image_url.xml', + ], +} diff --git a/web_search_date/readme/CONTRIBUTORS.rst b/web_search_date/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..93ec993e0 --- /dev/null +++ b/web_search_date/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Enric Tobella diff --git a/web_search_date/readme/DESCRIPTION.rst b/web_search_date/readme/DESCRIPTION.rst new file mode 100644 index 000000000..fc644a069 --- /dev/null +++ b/web_search_date/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Allows to search on dates with before and after directly on the search bar +without the "Extra filters". diff --git a/web_search_date/readme/USAGE.rst b/web_search_date/readme/USAGE.rst new file mode 100644 index 000000000..c2d6aa0fc --- /dev/null +++ b/web_search_date/readme/USAGE.rst @@ -0,0 +1,3 @@ +Write the date and the options `before`, `at` and `after` will be added. +You need to write at least the year and the month, for example: 2020-01 for +january 2020. diff --git a/web_search_date/static/description/icon.png b/web_search_date/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_search_date/static/description/icon.png differ diff --git a/web_search_date/static/description/index.html b/web_search_date/static/description/index.html new file mode 100644 index 000000000..7b7473e28 --- /dev/null +++ b/web_search_date/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Web Search Date + + + +
+

Web Search Date

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

Allows to search on dates with before and after directly on the search bar +without the “Extra filters”.

+

Table of contents

+ +
+

Usage

+

Write the date and the options before, at and after will be added. +You need to write at least the year and the month, for example: 2020-01 for +january 2020.

+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_search_date/static/src/js/widget.js b/web_search_date/static/src/js/widget.js new file mode 100644 index 000000000..3d18c4f7f --- /dev/null +++ b/web_search_date/static/src/js/widget.js @@ -0,0 +1,69 @@ +// Copyright 2017 - 2018 Modoolar +// License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). + +odoo.define('web_widget_search_date.Widget', function (require) { + "use strict"; + var core = require('web.core'); + var field_utils = require('web.field_utils'); + + var _t = core._t; + var DateField = core.search_widgets_registry.get("date"); + DateField.include({ + complete: function (needle) { + var t, v; + try { + t = (this.attrs && this.attrs.type === 'datetime') ? 'datetime' : 'date'; + v = field_utils.parse[t](needle, {type: t}, {timezone: true}); + } catch (e) { + return $.when(null); + } + var m = moment(v, t === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'); + if (!m.isValid()) { return $.when(null); } + var date_string = field_utils.format[t](m, {type: t}); + var before_label = _.str.sprintf(_.str.escapeHTML( + _t("Search %(field)s before: %(value)s")), { + field: '' + _.escape(this.attrs.string) + '', + value: '' + date_string + ''}); + var at_label = _.str.sprintf(_.str.escapeHTML( + _t("Search %(field)s at: %(value)s")), { + field: '' + _.escape(this.attrs.string) + '', + value: '' + date_string + ''}); + var after_label = _.str.sprintf(_.str.escapeHTML( + _t("Search %(field)s after: %(value)s")), { + field: '' + _.escape(this.attrs.string) + '', + value: '' + date_string + ''}); + var date = m.toDate(); + return $.when([ + { + label: before_label, + facet: { + category: this.attrs.string, + field: this, + values: [{label: '<=' + date_string, value: date, valueAsMoment: m, operator: '<=',}] + }, + }, { + label: at_label, + facet: { + category: this.attrs.string, + field: this, + values: [{label: date_string, value: date, valueAsMoment: m, operator: '=',}] + } + }, { + label: after_label, + facet: { + category: this.attrs.string, + field: this, + operator: '>=', + values: [{label: '>=' + date_string, value: date, valueAsMoment: m, operator: '>=',}] + } + }, + ]); + }, + make_domain: function (name, operator, facet) { + if (facet.attributes.operator != null) { + return [[name, facet.attributes.operator, this.value_from(facet)]]; + } + return this._super.apply(this, arguments); + }, + }); +}); diff --git a/web_search_date/views/web_widget_image_url.xml b/web_search_date/views/web_widget_image_url.xml new file mode 100644 index 000000000..199123ecb --- /dev/null +++ b/web_search_date/views/web_widget_image_url.xml @@ -0,0 +1,12 @@ + + + +