diff --git a/setup/web_filter_description/odoo/__init__.py b/setup/web_filter_description/odoo/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/setup/web_filter_description/odoo/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/web_filter_description/odoo/addons/__init__.py b/setup/web_filter_description/odoo/addons/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/setup/web_filter_description/odoo/addons/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/web_filter_description/odoo/addons/web_filter_description b/setup/web_filter_description/odoo/addons/web_filter_description new file mode 120000 index 00000000..b0ae7fed --- /dev/null +++ b/setup/web_filter_description/odoo/addons/web_filter_description @@ -0,0 +1 @@ +../../../../web_filter_description \ No newline at end of file diff --git a/setup/web_filter_description/setup.py b/setup/web_filter_description/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/web_filter_description/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_filter_description/README.rst b/web_filter_description/README.rst new file mode 100644 index 00000000..8c724f7a --- /dev/null +++ b/web_filter_description/README.rst @@ -0,0 +1,89 @@ +========================== +Add Description to filters +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/10.0/web_filter_description + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-10-0/web-10-0-web_filter_description + :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/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Add description for your custom filters + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +When you create a custom filter you can add a description to it. + +.. figure:: https://raw.githubusercontent.com/OCA/web/10.0/web_filter_description/static/description/screenshot_1.png + :scale: 80 % + :alt: Add a description + + +The description will be shown as tooltip after. + +.. figure:: https://raw.githubusercontent.com/OCA/web/10.0/web_filter_description/static/description/screenshot_2.png + :scale: 80 % + :alt: Show the description + +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 +~~~~~~~ + +* Bejaoui Souheil + +Contributors +~~~~~~~~~~~~ + +* Bejaoui Souheil + +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_filter_description/__init__.py b/web_filter_description/__init__.py new file mode 100644 index 00000000..567548c7 --- /dev/null +++ b/web_filter_description/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import models +from . import tests diff --git a/web_filter_description/__manifest__.py b/web_filter_description/__manifest__.py new file mode 100644 index 00000000..b984094f --- /dev/null +++ b/web_filter_description/__manifest__.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Bejaoui Souheil +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Add Description to filters", + "version": "10.0.1.0.0", + "author": "Bejaoui Souheil, Odoo Community Association (OCA)", + "license": "AGPL-3", + 'website': "https://github.com/OCA/web", + "summary": "Add description to filters", + "category": "Tools", + "depends": ['web'], + "data": ["views/assets.xml", "views/ir_filters.xml"], + 'qweb': ["static/src/xml/web_filter_description.xml"], + "installable": True, +} diff --git a/web_filter_description/models/__init__.py b/web_filter_description/models/__init__.py new file mode 100644 index 00000000..72f56381 --- /dev/null +++ b/web_filter_description/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import ir_filters diff --git a/web_filter_description/models/ir_filters.py b/web_filter_description/models/ir_filters.py new file mode 100644 index 00000000..e2d7e325 --- /dev/null +++ b/web_filter_description/models/ir_filters.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Bejaoui Souheil +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models, api + + +class IrFilters(models.Model): + _inherit = 'ir.filters' + + description = fields.Text(string="Description", required=False) + + @api.model + def get_filters(self, model, action_id=None): + res = super(IrFilters, self).get_filters(model, action_id) + ids = map(lambda f: f['id'], res) + # Browse filters that are in res + filters = self.browse(ids) + for i, res_filter in enumerate(res): + # Add the field 'description' to the result + res[i]['description'] = filters.filtered( + lambda f: f.id == res_filter['id'] + ).description + return res diff --git a/web_filter_description/readme/CONTRIBUTORS.rst b/web_filter_description/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..133ed47f --- /dev/null +++ b/web_filter_description/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Bejaoui Souheil diff --git a/web_filter_description/readme/DESCRIPTION.rst b/web_filter_description/readme/DESCRIPTION.rst new file mode 100644 index 00000000..9cf8d083 --- /dev/null +++ b/web_filter_description/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Add description for your custom filters diff --git a/web_filter_description/readme/USAGE.rst b/web_filter_description/readme/USAGE.rst new file mode 100644 index 00000000..9f889743 --- /dev/null +++ b/web_filter_description/readme/USAGE.rst @@ -0,0 +1,12 @@ +When you create a custom filter you can add a description to it. + +.. figure:: static/description/screenshot_1.png + :scale: 80 % + :alt: Add a description + + +The description will be shown as tooltip after. + +.. figure:: static/description/screenshot_2.png + :scale: 80 % + :alt: Show the description diff --git a/web_filter_description/static/description/icon.png b/web_filter_description/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/web_filter_description/static/description/icon.png differ diff --git a/web_filter_description/static/description/index.html b/web_filter_description/static/description/index.html new file mode 100644 index 00000000..d13531e5 --- /dev/null +++ b/web_filter_description/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +Add Description to filters + + + +
+

Add Description to filters

+ + +

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

+

Add description for your custom filters

+

Table of contents

+ +
+

Usage

+

When you create a custom filter you can add a description to it.

+
+Add a description +
+

The description will be shown as tooltip after.

+
+Show the description +
+
+
+

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

+
    +
  • Bejaoui Souheil
  • +
+
+
+

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_filter_description/static/description/screenshot_1.png b/web_filter_description/static/description/screenshot_1.png new file mode 100644 index 00000000..e26c6ce9 Binary files /dev/null and b/web_filter_description/static/description/screenshot_1.png differ diff --git a/web_filter_description/static/description/screenshot_2.png b/web_filter_description/static/description/screenshot_2.png new file mode 100644 index 00000000..8c5c252c Binary files /dev/null and b/web_filter_description/static/description/screenshot_2.png differ diff --git a/web_filter_description/static/src/js/web_filter_description.js b/web_filter_description/static/src/js/web_filter_description.js new file mode 100644 index 00000000..e6a92832 --- /dev/null +++ b/web_filter_description/static/src/js/web_filter_description.js @@ -0,0 +1,47 @@ +/* * + Copyright 2018 Bejaoui Souheil + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + */ +odoo.define('web_filter_description.web_filter_description', function(require) { + "use strict"; + var session = require('web.session'); + var data_manager = require('web.data_manager'); + var FavoriteMenu = require('web.FavoriteMenu'); + + FavoriteMenu.include({ + start: function() { + this.$save_name = this.$('.o_save_name'); + this.$textarea = this.$save_name.find('textarea'); + return this._super(); + }, + save_favorite: function() { + var self = this, + filter_name = this.$inputs[0].value, + description = this.$textarea[0].value, + shared_filter = this.$inputs[2].checked; + return $.when(this._super()).then(function() { + var filter_key = self.key_for({ + name: filter_name, + user_id: shared_filter ? false : session.uid, + model_id: self.target_model, + action_id: self.action_id, + }); + var filter = self.filters[filter_key]; + if (filter) { + filter.description = description; + return data_manager.create_filter(filter); + } + }); + }, + append_filter: function(filter) { + var self = this, + filter_name = filter.name, + filter_description = filter.description, + filter_key = self.key_for(filter); + $.when(this._super(filter)).then(function() { + self.$filters[filter_key].prop('title', filter_description ? filter_description : filter_name); + }); + }, + }); + +}); diff --git a/web_filter_description/static/src/xml/web_filter_description.xml b/web_filter_description/static/src/xml/web_filter_description.xml new file mode 100644 index 00000000..71d32e60 --- /dev/null +++ b/web_filter_description/static/src/xml/web_filter_description.xml @@ -0,0 +1,17 @@ + + + + + + +
  • +
    + + +
    +
  • +
    +
    + +
    diff --git a/web_filter_description/tests/__init__.py b/web_filter_description/tests/__init__.py new file mode 100644 index 00000000..790630df --- /dev/null +++ b/web_filter_description/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ir_filters diff --git a/web_filter_description/tests/test_ir_filters.py b/web_filter_description/tests/test_ir_filters.py new file mode 100644 index 00000000..9a7781a5 --- /dev/null +++ b/web_filter_description/tests/test_ir_filters.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Bejaoui Souheil +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestIrFilters(TransactionCase): + def setUp(self): + super(TestIrFilters, self).setUp() + self.filter_object = self.env['ir.filters'].create( + { + 'name': 'custom filter', + 'model_id': 'ir.module.module', + 'domain': '[]', + 'user_id': False, + 'description': 'custom filter description', + } + ) + + def test_create_filter_with_description(self): + res = self.env['ir.filters'].get_filters(model='ir.module.module') + if res: + self.assertIn('description', res[0].keys()) + self.assertIn( + 'custom filter description', + list(map(lambda f: f['description'], res)), + ) diff --git a/web_filter_description/views/assets.xml b/web_filter_description/views/assets.xml new file mode 100644 index 00000000..27307bc0 --- /dev/null +++ b/web_filter_description/views/assets.xml @@ -0,0 +1,12 @@ + + + +