diff --git a/pos_lock_session/README.rst b/pos_lock_session/README.rst new file mode 100644 index 000000000..00e6645f3 --- /dev/null +++ b/pos_lock_session/README.rst @@ -0,0 +1,54 @@ +==================== +POS Session Lock V11 +==================== + +This module allows pos user to lock pos screen. + +Installation +============ + +- www.odoo.com/documentation/10.0/setup/install.html +- Install our custom addon + + +Configuration +============= + +* Using the Boolean button in POS configuration you can enable screen lock. +* Security pin for each pos user can be set from Point of Sale tab under Settings -> Users -> Users. + + +Features +======== + +* Screen lock option in POS session configuration. +* Screen lock button in pos. +* Lock screen using keyboard shortcut 'CTRL+L'. +* Login/Unlock screen in pos. +* Extra layer of security. + + +License +======= +GNU LESSER GENERAL PUBLIC LICENSE, Version 3 (LGPLv3) +(http://www.gnu.org/licenses/agpl.html) + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + +Author +------ + +Developer: Aswani PC @ cybrosys, aswani@cybrosys.in + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/pos_lock_session/__init__.py b/pos_lock_session/__init__.py new file mode 100644 index 000000000..8e3a966e0 --- /dev/null +++ b/pos_lock_session/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# +# 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 models diff --git a/pos_lock_session/__manifest__.py b/pos_lock_session/__manifest__.py new file mode 100644 index 000000000..68eb824ab --- /dev/null +++ b/pos_lock_session/__manifest__.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# +# 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': "POS Session Lock", + 'version': '11.0.1.0.0', + 'summary': """The Module Allows the POS User to Set Screen Lock for POS Screen""", + 'description': """This module allows pos user to lock pos screen.""", + 'author': "Cybrosys Techno Solutions", + 'maintainer': 'Cybrosys Techno Solutions', + 'company': "Cybrosys Techno Solutions", + 'website': "https://www.cybrosys.com", + 'category': 'Point of Sale', + 'depends': ['point_of_sale'], + 'data': [ + 'views/pos_lock.xml', + 'views/pos_templates.xml', + ], + 'qweb': ['static/src/xml/session_lock.xml'], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/pos_lock_session/models/__init__.py b/pos_lock_session/models/__init__.py new file mode 100644 index 000000000..9e296cc7a --- /dev/null +++ b/pos_lock_session/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import pos_lock diff --git a/pos_lock_session/models/pos_lock.py b/pos_lock_session/models/pos_lock.py new file mode 100644 index 000000000..c2c3196d4 --- /dev/null +++ b/pos_lock_session/models/pos_lock.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields + + +class PosLockConfig(models.Model): + _inherit = 'pos.config' + + pos_lock = fields.Boolean(string='Enable Lock Screen') + bg_color = fields.Char('Background Color', default='rgb(218, 218, 218)', + help='The background color of the lock screen, ' + '(must be specified in a html-compatible format)') diff --git a/pos_lock_session/static/description/banner.jpg b/pos_lock_session/static/description/banner.jpg new file mode 100644 index 000000000..aca853b8e Binary files /dev/null and b/pos_lock_session/static/description/banner.jpg differ diff --git a/pos_lock_session/static/description/cybro_logo.png b/pos_lock_session/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/pos_lock_session/static/description/cybro_logo.png differ diff --git a/pos_lock_session/static/description/icon.png b/pos_lock_session/static/description/icon.png new file mode 100644 index 000000000..54a21af32 Binary files /dev/null and b/pos_lock_session/static/description/icon.png differ diff --git a/pos_lock_session/static/description/index.html b/pos_lock_session/static/description/index.html new file mode 100644 index 000000000..ebfb75b2a --- /dev/null +++ b/pos_lock_session/static/description/index.html @@ -0,0 +1,347 @@ +
+
+

+ POS Session Lock +

+

+ Lock Pos Screen +

+
+ Cybrosys Technologies +
+ +
+ cybrosys technologies
+
+
+
+
+
+

+ Overview +

+

+ The module allows the POS user to set screen lock for his/her POS screen when it is left unattended. The lock feature will provide an extra layer security for individual POS. +

+
+
+
+
+

+ Features +

+

+ + Screen lock option in POS session configuration. +

+

+ + Screen lock button in POS. +

+

+ + Lock screen using keyboard shortcut 'CTRL+L'. +

+

+ + Login/Unlock screen in pos. +

+

+ + Extra layer of security. +

+
+
+
+
+

+ Screenshots +

+

+ + Configuration +

+ Using the newly appeared Boolean button in POS configuration user can enable screen lock option. +

+ +
+ +
+

+ + Lock Screen +

+
+ +
+

+ + Login/Unlock Screen +

+
+ +
+
+
+
+
+

+ Our Services +

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

+ + Odoo Support +

+ +
+ +
+
+
+
+
+

+ Our Industries +

+
+ +
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Manufacturing +

+

+ Plan, track and schedule your operations. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Restaurant +

+

+ Run your bar or restaurant methodical. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + POS +

+

+ Easy configuring and convivial selling. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + E-commerce & Website +

+

+ Mobile friendly, awe-inspiring product pages. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Hotel Management +

+

+ An all-inclusive hotel management application. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Education +

+

+ A Collaborative platform for educational management. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Service Management +

+

+ Keep track of services and invoice accordingly. +

+
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/pos_lock_session/static/description/pos_session_lock_01.png b/pos_lock_session/static/description/pos_session_lock_01.png new file mode 100644 index 000000000..d4c1225f6 Binary files /dev/null and b/pos_lock_session/static/description/pos_session_lock_01.png differ diff --git a/pos_lock_session/static/description/pos_session_lock_02.png b/pos_lock_session/static/description/pos_session_lock_02.png new file mode 100644 index 000000000..57a52853b Binary files /dev/null and b/pos_lock_session/static/description/pos_session_lock_02.png differ diff --git a/pos_lock_session/static/description/pos_session_lock_03.png b/pos_lock_session/static/description/pos_session_lock_03.png new file mode 100644 index 000000000..997a6fe1d Binary files /dev/null and b/pos_lock_session/static/description/pos_session_lock_03.png differ diff --git a/pos_lock_session/static/src/css/session_lock.css b/pos_lock_session/static/src/css/session_lock.css new file mode 100644 index 000000000..9c4e613e8 --- /dev/null +++ b/pos_lock_session/static/src/css/session_lock.css @@ -0,0 +1,53 @@ +.login-screen{ + position:fixed !important; +} +.pos .modal-dialog .screen_lock{ + position: absolute; + top: 0; left: 0; right: 0; bottom: 0; + margin: auto; + width:100px; + height:100px; + text-align:center; + border-radius: 3px; + z-index:1200; +} + +.pos .modal-dialog .screen_lock .fa-lock { + position: absolute; + left: 13px; + top: 13px; + color:black; + font-size: 100px; + border-radius: 100%; +} + +.pos_login .fa-arrow-circle-right { + font-size: 40px; + background: #FFFFFF; + color: rgb(0,128,0); + line-height: 30px; + width: 30px; + border-radius: 100%; + margin-top: 8px; +} + +.back_pos .fa-arrow-circle-left { + position: absolute; + left: 13px; + top: 13px; + margin-right: 8px; + font-size: 40px; + background: #FFFFFF; + color: red; + line-height: 30px; + width: 30px; + border-radius: 100%; +} + +.pos_invalid_password{ + color: red; +} + +.login-picture{ + padding-top:130px; +} \ No newline at end of file diff --git a/pos_lock_session/static/src/js/session_lock.js b/pos_lock_session/static/src/js/session_lock.js new file mode 100644 index 000000000..8e71ee87c --- /dev/null +++ b/pos_lock_session/static/src/js/session_lock.js @@ -0,0 +1,109 @@ +odoo.define('pos_lock_session.session_lock', function (require) { +"use strict"; + +var core = require('web.core'); +var chrome = require('point_of_sale.chrome'); +var gui = require('point_of_sale.gui'); +var PopupWidget = require('point_of_sale.popups'); +var _t = core._t; + +var SessionLock = PopupWidget.extend({ + template:'SessionLock', + events: _.extend({}, PopupWidget.prototype.events,{ + "click .screen_lock" : "unlock_screen", + }), + show: function(options){ + var self = this; + this._super(options); + $(document).keydown(function(e) { + if(e.keyCode == 13) { + e.preventDefault(); + self.gui.show_screen('login',{lock:true}); + } + }); + }, + unlock_screen:function(){ + var self = this; + this.gui.show_screen('login',{lock:true}); + } +}); +gui.define_popup({name:'lock', widget: SessionLock}); + + +chrome.Chrome.include({ + events: { + "click .pos-lock": "on_click_pos_lock", + }, + + init: function() { + var self = this; + this._super(); + $(document).keydown(function(e) { + if(self.pos.config.pos_lock){ + if(e.keyCode == 76 && e.ctrlKey) { + e.preventDefault(); + e.stopPropagation(); + var cashier = this.get_cashier().id; + for (var i = 0; i < this.users.length; i++) { + var user = this.users[i]; + if (user.id === cashier) { + var cashier_pswd = user.pos_security_pin; + } + } + if(!cashier_pswd){ + self.gui.show_popup('error', { + 'title': _t('Security pin is not set'), + 'body': _t('Please set a security pin.'), + }); + } + else{ + self.gui.show_popup('lock',{}); + } + } + } + }); + }, + renderElement: function(){ + var self = this; + return this._super(); + + }, + + build_widgets: function(){ + this._super(); + var cashier = this.pos.get_cashier().id; + for (var i = 0; i < this.pos.users.length; i++) { + var user = this.pos.users[i]; + if (user.id === cashier) { + var cashier_pswd = user.pos_security_pin; + } + } + if (this.pos.config.pos_lock && cashier_pswd) { + this.gui.set_startup_screen('login'); + } + }, + + on_click_pos_lock: function (e) { + var self = this; + e.stopPropagation(); + var cashier = this.pos.get_cashier().id; + for (var i = 0; i < this.pos.users.length; i++) { + var user = this.pos.users[i]; + if (user.id === cashier) { + var cashier_pswd = user.pos_security_pin; + } + } + if(!cashier_pswd){ + this.gui.show_popup('error', { + 'title': _t('Security pin is not set'), + 'body': _t('Please set a security pin.'), + }); + } + else{ + self.gui.show_popup('lock',{}); + } + }, + +}); + +}); \ No newline at end of file diff --git a/pos_lock_session/static/src/js/unlock_screen.js b/pos_lock_session/static/src/js/unlock_screen.js new file mode 100644 index 000000000..b59086640 --- /dev/null +++ b/pos_lock_session/static/src/js/unlock_screen.js @@ -0,0 +1,125 @@ +odoo.define('pos_lock_session.screen', function (require) { +"use strict"; + +var screens = require('point_of_sale.screens'); +var gui = require('point_of_sale.gui'); +var models = require('point_of_sale.models'); +var _super_posmodel = models.PosModel.prototype; + +var _t = require('web.core')._t; + +var LoginScreenWidget = screens.ScreenWidget.extend({ + template: 'LoginScreenWidget', + + barcode_product_action: function(code){}, + barcode_discount_action: function(code){}, + barcode_client_action: function(code){}, + + init: function(parent, options) { + this._super(parent, options); + + }, + + show: function(){ + var self = this; + this._super(); + this.renderElement(); + this.$('.pos_invalid_password').val(''); + this.$('.user_password').val(''); + var cashier = this.pos.get_cashier().id; + for (var i = 0; i < this.pos.users.length; i++) { + var user = this.pos.users[i]; + if (user.id === cashier) { + this.user = user; + } + } + // this.user = this.pos.get_cashier(); + this.chrome.$('.pos-topheader').hide(); + if(this.pos.config.iface_vkeyboard && this.chrome.widget.keyboard){ + this.chrome.widget.keyboard.connect(this.$('.user_password')); + } + this.$el.css({"background-color": _.escape(this.pos.config.bg_color)}); + if (! this.user.pos_security_pin){ + self.$('.pos_invalid_password').text('Please set a security pin.'); + } + this.$('.back').click(function(){ + if (self.gui.get_current_screen_param('lock')){ + self.gui.show_screen('products'); + self.chrome.$('.pos-topheader').show(); + if(self.pos.config.iface_vkeyboard && self.chrome.widget.keyboard){ + self.chrome.widget.keyboard.hide(); + } + self.gui.show_popup('lock',{}); + } + else{ + self.gui.close(); + } + + }); + this.$('.login').click(function(){ + if (self.$('.user_password').val() === self.user.pos_security_pin){ + if (!self.gui.get_current_screen_param('lock')){ + _super_posmodel.set_start_order.call(self.pos); + } + self.gui.show_screen('products'); + self.chrome.$('.pos-topheader').show(); + if(self.pos.config.iface_vkeyboard && self.chrome.widget.keyboard){ + self.chrome.widget.keyboard.hide(); + } + } + else{ + self.$('.pos_invalid_password').text('Invalid Password'); + } + }); + $(document).keyup(function(e) { + if(e.keyCode == 13) { + e.preventDefault(); + e.stopPropagation(); + if (self.$('.user_password').val() === self.user.pos_security_pin){ + if (!self.gui.get_current_screen_param('lock')){ + _super_posmodel.set_start_order.call(self.pos); + } + self.gui.show_screen('products'); + self.chrome.$('.pos-topheader').show(); + if(self.pos.config.iface_vkeyboard && self.chrome.widget.keyboard){ + self.chrome.widget.keyboard.hide(); + } + } + else{ + self.$('.pos_invalid_password').text('Invalid Password'); + } + } + }); + }, + user_icon_url: function(id){ + return '/web/image?model=res.users&id='+id+'&field=image'; + }, + +}); + +gui.define_screen({ + 'name': 'login', + 'widget': LoginScreenWidget, + 'condition': function(){ + return this.pos.config.pos_lock; + }, +}); + +models.PosModel = models.PosModel.extend({ + // set when the user login to session. + set_start_order: function() { + var cashier = this.get_cashier().id; + for (var i = 0; i < this.users.length; i++) { + var user = this.users[i]; + if (user.id === cashier) { + var cashier_pswd = user.pos_security_pin; + } + } + if (!this.config.pos_lock || !cashier_pswd) { + _super_posmodel.set_start_order.apply(this,arguments); + } + }, + +}); + +}); \ No newline at end of file diff --git a/pos_lock_session/static/src/xml/session_lock.xml b/pos_lock_session/static/src/xml/session_lock.xml new file mode 100644 index 000000000..a9e605816 --- /dev/null +++ b/pos_lock_session/static/src/xml/session_lock.xml @@ -0,0 +1,47 @@ + + + + + + +
+ +
+
+
+
+ + + + + + +