14 changed files with 342 additions and 0 deletions
			
			
		@ -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 <https://www.cybrosys.com> | 
				
			||||
@ -0,0 +1,23 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    Cybrosys Technologies Pvt. Ltd. | 
				
			||||
 | 
					#    Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>). | 
				
			||||
 | 
					#    Author: Avinash Nk(<https://www.cybrosys.com>) | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    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 <https://www.gnu.org/licenses/>. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					from . import controllers | 
				
			||||
@ -0,0 +1,38 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    Cybrosys Technologies Pvt. Ltd. | 
				
			||||
 | 
					#    Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>). | 
				
			||||
 | 
					#    Author: Avinash Nk(<https://www.cybrosys.com>) | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    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 <https://www.gnu.org/licenses/>. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					    '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, | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,23 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    Cybrosys Technologies Pvt. Ltd. | 
				
			||||
 | 
					#    Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>). | 
				
			||||
 | 
					#    Author: Avinash Nk(<https://www.cybrosys.com>) | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    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 <https://www.gnu.org/licenses/>. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					from . import main | 
				
			||||
@ -0,0 +1,42 @@ | 
				
			|||||
 | 
					# -*- coding: utf-8 -*- | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    Cybrosys Technologies Pvt. Ltd. | 
				
			||||
 | 
					#    Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>). | 
				
			||||
 | 
					#    Author: Avinash Nk(<https://www.cybrosys.com>) | 
				
			||||
 | 
					# | 
				
			||||
 | 
					#    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 <https://www.gnu.org/licenses/>. | 
				
			||||
 | 
					# | 
				
			||||
 | 
					################################################################################### | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					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 | 
				
			||||
| 
		 After Width: | Height: | Size: 10 MiB  | 
| 
		 After Width: | Height: | Size: 409 KiB  | 
| 
		 After Width: | Height: | Size: 50 KiB  | 
| 
		 After Width: | Height: | Size: 14 KiB  | 
@ -0,0 +1,91 @@ | 
				
			|||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced o_animate o_animate_in_children o_animate_offset_min"> | 
				
			||||
 | 
					        <h2 class="oe_slogan">Auto Fill Widget</h2> | 
				
			||||
 | 
					        <h3 class="oe_slogan">Widget that suggests field value in existing records</h3> | 
				
			||||
 | 
					        <h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a></h4> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced o_animate o_animate_in_children o_animate_offset_min" style="padding-left:65px;"> | 
				
			||||
 | 
					        <h4>Features:</h4> | 
				
			||||
 | 
					        <div> | 
				
			||||
 | 
					            <br/> | 
				
			||||
 | 
					            <span style="color:green;"> ☑ </span> Can put any character or text fields<br/> | 
				
			||||
 | 
					            <br/> | 
				
			||||
 | 
					            <span style="color:green;"> ☑ </span> Very fast results<br/> | 
				
			||||
 | 
					            <br/> | 
				
			||||
 | 
					            <span style="color:green;"> ☑ </span> Attractive design<br/> | 
				
			||||
 | 
					            <br/> | 
				
			||||
 | 
					            <span style="color:green;"> ☑ </span> Widget = <b>auto_fill</b><br/> | 
				
			||||
 | 
					            <br/> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container oe_dark"> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced o_animate o_animate_in_children o_animate_offset_min"> | 
				
			||||
 | 
					        <div class="oe_picture"> | 
				
			||||
 | 
					            <h3 class="oe_slogan">Overview</h3> | 
				
			||||
 | 
					            <p class="oe_mt32 text-justify"> | 
				
			||||
 | 
					                Widget for auto completing a character field according to its existing record values | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced o_animate o_animate_in_children o_animate_offset_min"> | 
				
			||||
 | 
					        <div style="text-align: center"> | 
				
			||||
 | 
					            <p> | 
				
			||||
 | 
					            <h3 class="oe_slogan">Configuration</h3> | 
				
			||||
 | 
					            <p> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					        <div class="oe_picture" style="text-align:center"> | 
				
			||||
 | 
					            <p class="oe_mt32 text-justify"> | 
				
			||||
 | 
					                After installing the module, you can put the tag <b>widget="auto_fill"</b> in your form view. Then it | 
				
			||||
 | 
					                works as below. | 
				
			||||
 | 
					            </p> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container oe_dark"> | 
				
			||||
 | 
					    <div class="oe_row oe_spaced o_animate o_animate_in_children o_animate_offset_min"> | 
				
			||||
 | 
					        <div class="oe_picture" style="text-align: center"> | 
				
			||||
 | 
					            <div class="oe_demo oe_picture oe_screenshot"> | 
				
			||||
 | 
					                <img style="border:10px solid white;" src="auto_fill.gif"> | 
				
			||||
 | 
					            </div> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<section class="oe_container"> | 
				
			||||
 | 
					    <h2 class="oe_slogan" style="margin-top:20px;">Need Any Help?</h2> | 
				
			||||
 | 
					    <div class="oe_slogan" style="margin-top:10px !important;"> | 
				
			||||
 | 
					        <div> | 
				
			||||
 | 
					            <a class="btn btn-primary btn-lg mt8" | 
				
			||||
 | 
					               style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i | 
				
			||||
 | 
					                    class="fa fa-envelope"></i> Email </a> <a | 
				
			||||
 | 
					                class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" | 
				
			||||
 | 
					                href="https://www.cybrosys.com/contact/"><i | 
				
			||||
 | 
					                class="fa fa-phone"></i> Contact Us </a> <a | 
				
			||||
 | 
					                class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;" | 
				
			||||
 | 
					                href="https://www.cybrosys.com/odoo-customization-and-installation/"><i | 
				
			||||
 | 
					                class="fa fa-check-square"></i> Request Customization </a> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					        <br> | 
				
			||||
 | 
					        <img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block"> | 
				
			||||
 | 
					        <div> | 
				
			||||
 | 
					            <a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" | 
				
			||||
 | 
					                                                                      style="color:white;background: #00a0d1;width:35px;"></i></a></td> | 
				
			||||
 | 
					            <a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i | 
				
			||||
 | 
					                    class="fa fa-2x fa-linkedin" | 
				
			||||
 | 
					                    style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td> | 
				
			||||
 | 
					            <a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" | 
				
			||||
 | 
					                                                                                       style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td> | 
				
			||||
 | 
					            <a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i | 
				
			||||
 | 
					                    class="fa fa-2x fa-google-plus" | 
				
			||||
 | 
					                    style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td> | 
				
			||||
 | 
					            <a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" | 
				
			||||
 | 
					                                                                           style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</section> | 
				
			||||
@ -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; | 
				
			||||
 | 
					} | 
				
			||||
@ -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, | 
				
			||||
 | 
					    }; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					}); | 
				
			||||
@ -0,0 +1,17 @@ | 
				
			|||||
 | 
					<?xml version="1.0" encoding="UTF-8"?> | 
				
			||||
 | 
					<templates> | 
				
			||||
 | 
					    <t t-name="FieldAutoFill"> | 
				
			||||
 | 
					        <t t-if="widget.mode !== 'readonly'"> | 
				
			||||
 | 
					            <t t-if="widget.formatType === 'char'"> | 
				
			||||
 | 
					                <input type="text" id="input_field_auto_fill" class="o_input input_field_auto_fill"/> | 
				
			||||
 | 
					            </t> | 
				
			||||
 | 
					            <t t-if="widget.formatType === 'text'"> | 
				
			||||
 | 
					                <textarea type="text" id="input_field_auto_fill" class="o_input text_field_auto_fill"/> | 
				
			||||
 | 
					            </t> | 
				
			||||
 | 
					        </t> | 
				
			||||
 | 
					        <span t-if="widget.mode === 'readonly'"/> | 
				
			||||
 | 
					        <div t-if="widget.mode !== 'readonly'" class="auto-fill-scrollbar" id="auto_fill_list_scroll"> | 
				
			||||
 | 
					            <table id="list_matches" class="list_matches"/> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </t> | 
				
			||||
 | 
					</templates> | 
				
			||||
@ -0,0 +1,11 @@ | 
				
			|||||
 | 
					<?xml version="1.0" encoding="UTF-8"?> | 
				
			||||
 | 
					<odoo> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    <template id="assets_backend" inherit_id="web.assets_backend"> | 
				
			||||
 | 
					        <xpath expr="." position="inside"> | 
				
			||||
 | 
					            <link rel="stylesheet" href="/auto_fill/static/src/css/auto_fill.css"/> | 
				
			||||
 | 
					            <script src="/auto_fill/static/src/js/auto_fill.js" type="text/javascript"/> | 
				
			||||
 | 
					        </xpath> | 
				
			||||
 | 
					    </template> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					</odoo> | 
				
			||||
					Loading…
					
					
				
		Reference in new issue