diff --git a/auto_fill/README.rst b/auto_fill/README.rst new file mode 100755 index 000000000..186d69841 --- /dev/null +++ b/auto_fill/README.rst @@ -0,0 +1,12 @@ +Auto Fill Widget +================ +* Widget that suggests field value in existing records +* Widget = **auto_fill** + +Developer +========= +* Developer: Avinash Nk (avinash@cybrosys.in) + +Contacts +======== +* Cybrosys Technologies diff --git a/auto_fill/__init__.py b/auto_fill/__init__.py new file mode 100755 index 000000000..a7d50eeee --- /dev/null +++ b/auto_fill/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Avinash Nk() +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 . +# +################################################################################### + +from . import controllers diff --git a/auto_fill/__manifest__.py b/auto_fill/__manifest__.py new file mode 100755 index 000000000..bc6d79720 --- /dev/null +++ b/auto_fill/__manifest__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Avinash Nk() +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 . +# +################################################################################### +{ + 'name': 'Auto Fill Widget', + 'version': '11.0.1.0.0', + 'summary': """Widget that suggests field value in existing records""", + 'description': 'Widget for auto completing a character field according to its existing record values', + 'category': 'Extra Tools', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base'], + 'data': ['views/auto_fill_templates.xml'], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/auto_fill/controllers/__init__.py b/auto_fill/controllers/__init__.py new file mode 100755 index 000000000..e56d9d4e0 --- /dev/null +++ b/auto_fill/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Avinash Nk() +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 . +# +################################################################################### + +from . import main diff --git a/auto_fill/controllers/main.py b/auto_fill/controllers/main.py new file mode 100755 index 000000000..a98f1d8a9 --- /dev/null +++ b/auto_fill/controllers/main.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Avinash Nk() +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) 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 . +# +################################################################################### + +from odoo.http import request +from odoo import http + + +class GetMatchingRecords(http.Controller): + + @http.route(['/matching/records'], type='json', auth="none") + def get_matching_records(self, **kwargs): + model = str(kwargs['model']) + field = str(kwargs['field']) + value = str(kwargs['value']) + model = model.replace(".", "_") + cr = request.cr + if len(value) > 0: + query = """SELECT %s FROM %s WHERE %s ~* '%s' GROUP BY %s""" % (field, model, field, value, field) + cr.execute(query) + res = cr.fetchall() + else: + res = [] + return res diff --git a/auto_fill/static/description/auto_fill.gif b/auto_fill/static/description/auto_fill.gif new file mode 100755 index 000000000..4f3aecdcc Binary files /dev/null and b/auto_fill/static/description/auto_fill.gif differ diff --git a/auto_fill/static/description/banner.jpg b/auto_fill/static/description/banner.jpg new file mode 100755 index 000000000..434e8bfe3 Binary files /dev/null and b/auto_fill/static/description/banner.jpg differ diff --git a/auto_fill/static/description/cybro_logo.png b/auto_fill/static/description/cybro_logo.png new file mode 100755 index 000000000..bb309114c Binary files /dev/null and b/auto_fill/static/description/cybro_logo.png differ diff --git a/auto_fill/static/description/icon.png b/auto_fill/static/description/icon.png new file mode 100755 index 000000000..538cbf146 Binary files /dev/null and b/auto_fill/static/description/icon.png differ diff --git a/auto_fill/static/description/index.html b/auto_fill/static/description/index.html new file mode 100755 index 000000000..c0097ebb3 --- /dev/null +++ b/auto_fill/static/description/index.html @@ -0,0 +1,91 @@ +
+
+

Auto Fill Widget

+

Widget that suggests field value in existing records

+

Cybrosys Technologies

+
+
+

Features:

+
+
+ Can put any character or text fields
+
+ Very fast results
+
+ Attractive design
+
+ Widget = auto_fill
+
+
+
+
+ +
+
+
+

Overview

+

+ Widget for auto completing a character field according to its existing record values +

+
+
+
+ +
+
+
+

+

Configuration

+

+

+
+

+ After installing the module, you can put the tag widget="auto_fill" in your form view. Then it + works as below. +

+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
diff --git a/auto_fill/static/src/css/auto_fill.css b/auto_fill/static/src/css/auto_fill.css new file mode 100755 index 000000000..62b1e0e4d --- /dev/null +++ b/auto_fill/static/src/css/auto_fill.css @@ -0,0 +1,32 @@ +.auto-fill-scrollbar { + z-index: 1051; + position: absolute; + background: #ffffff; + overflow-y: scroll; + height: auto; + display:none; + width:auto !important; + border: 1px solid #E5E5E5; + font-size: 13px; + padding: 5px 0px; + box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.176); +} +.auto-fill-scrollbar td { + padding-left: 7px !important; + padding-right: 7px !important; +} +.auto-fill-scrollbar td:hover{ + background: #2d6cb3; + color: #fff; + width: 5px; +} +.list_matches{ + width: 100%; + cursor: pointer; +} +.input_field_auto_fill { + border: 1px solid #D2D2FF; +} +.text_field_auto_fill { + border: 1px solid #D2D2FF; +} diff --git a/auto_fill/static/src/js/auto_fill.js b/auto_fill/static/src/js/auto_fill.js new file mode 100755 index 000000000..6073b3965 --- /dev/null +++ b/auto_fill/static/src/js/auto_fill.js @@ -0,0 +1,53 @@ +odoo.define('auto_fill.AutoFill', function (require) { + "use strict"; + + var ajax = require('web.ajax'); + var basic_fields = require('web.basic_fields'); + var registry = require('web.field_registry'); + var CharField = registry.get('char'); + + var FieldAutoFill = CharField.extend({ + template: 'FieldAutoFill', + events: _.extend({}, CharField.prototype.events, { + 'keyup': '_onKeyup', + 'click #list_matches': '_onTableRowClicked', + }), + + _onKeyup: function () { + var value = document.getElementsByClassName('input_field_auto_fill')[0].value; + ajax.jsonRpc('/matching/records', 'call', { + model: this.model, + field: this.name, + value: value, + }).then(function (result){ + if (result.length > 0){ + $('.auto-fill-scrollbar').css('display', 'block'); + var table = document.getElementById("list_matches"); + $("#list_matches tr").remove(); + var i; + for (i = 0; i < result.length; i++) { + var row = table.insertRow(i); + var cell = row.insertCell(0); + cell.innerHTML = result[i]; + } + } + else { + $('.auto-fill-scrollbar').css('display', 'none'); + } + }) ; + }, + + _onTableRowClicked: function (ev) { + document.getElementsByClassName('input_field_auto_fill')[0].value = ev.target.textContent; + $('.auto-fill-scrollbar').css('display', 'none'); + }, + + }); + + registry.add('auto_fill', FieldAutoFill); + + return { + FieldAutoFill: FieldAutoFill, + }; + +}); diff --git a/auto_fill/static/src/xml/auto_fill.xml b/auto_fill/static/src/xml/auto_fill.xml new file mode 100755 index 000000000..f34bdc2d6 --- /dev/null +++ b/auto_fill/static/src/xml/auto_fill.xml @@ -0,0 +1,17 @@ + + + + + + + + +