Browse Source

[ADD] Initial Commit

pull/57/head
Sreejith 8 years ago
parent
commit
71171e8e2d
  1. 54
      pos_lock_session/README.rst
  2. 22
      pos_lock_session/__init__.py
  3. 43
      pos_lock_session/__manifest__.py
  4. 3
      pos_lock_session/models/__init__.py
  5. 12
      pos_lock_session/models/pos_lock.py
  6. BIN
      pos_lock_session/static/description/banner.jpg
  7. BIN
      pos_lock_session/static/description/cybro_logo.png
  8. BIN
      pos_lock_session/static/description/icon.png
  9. 96
      pos_lock_session/static/description/index.html
  10. BIN
      pos_lock_session/static/description/pos_session_lock_01.png
  11. BIN
      pos_lock_session/static/description/pos_session_lock_02.png
  12. BIN
      pos_lock_session/static/description/pos_session_lock_03.png
  13. 53
      pos_lock_session/static/src/css/session_lock.css
  14. 109
      pos_lock_session/static/src/js/session_lock.js
  15. 125
      pos_lock_session/static/src/js/unlock_screen.js
  16. 47
      pos_lock_session/static/src/xml/session_lock.xml
  17. 21
      pos_lock_session/views/pos_lock.xml
  18. 12
      pos_lock_session/views/pos_templates.xml

54
pos_lock_session/README.rst

@ -0,0 +1,54 @@
====================
POS Session Lock V10
====================
This module allows pos user to lock pos screen.
Installation
============
- www.odoo.com/documentation/11.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<https://www.cybrosys.com>
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.

22
pos_lock_session/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Aswani PC(<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 models

43
pos_lock_session/__manifest__.py

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Aswani PC(<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': "POS Session Lock",
'version': '10.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,
}

3
pos_lock_session/models/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import pos_lock

12
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)')

BIN
pos_lock_session/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
pos_lock_session/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
pos_lock_session/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

96
pos_lock_session/static/description/index.html

@ -0,0 +1,96 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">POS Session Lock</h2>
<h3 class="oe_slogan">Lock Pos Screen</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a></h4>
</div>
<div class="oe_row oe_spaced" style="padding-left:65px;">
<h4>Features:</h4>
<div>
<span style="color:green;"> &#9745; </span>Screen lock option in POS session configuration.<br/>
<span style="color:green;"> &#9745; </span>Screen lock button in POS.<br/>
<span style="color:green;"> &#9745; </span>Lock screen using keyboard shortcut 'CTRL+L'.<br/>
<span style="color:green;"> &#9745; </span>Login/Unlock screen in pos.<br/>
<span style="color:green;"> &#9745; </span>Extra layer of security.<br/>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="" style="text-align: center;">
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">
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.
</p>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="" style="text-align: center;">
<h3 class="oe_slogan">Configuration</h3>
<p>Using the newly appeared Boolean button in POS configuration user can enable screen lock option.</p>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="pos_session_lock_01.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="" style="text-align: center;">
<h3 class="oe_slogan">Lock Screen</h3>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="pos_session_lock_02.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="" style="text-align: center;">
<h3 class="oe_slogan">Login/Unlock Screen</h3>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="pos_session_lock_03.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<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>

BIN
pos_lock_session/static/description/pos_session_lock_01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

BIN
pos_lock_session/static/description/pos_session_lock_02.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

BIN
pos_lock_session/static/description/pos_session_lock_03.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

53
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;
}

109
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',{});
}
},
});
});

125
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);
}
},
});
});

47
pos_lock_session/static/src/xml/session_lock.xml

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="Chrome">
<t t-jquery="div.pos-rightheader" t-operation="append">
<t t-if='widget.pos.config and widget.pos.config.pos_lock'>
<div class="oe_status">
<i class="fa fa-lock pos-lock"/>
</div>
</t>
</t>
</t>
<t t-name="SessionLock">
<div class="modal-dialog">
<div class='screen_lock'>
<i class='fa fa-lock' />
</div>
</div>
</t>
<t t-name="LoginScreenWidget">
<div class='login-screen screen'>
<div class='screen-content-flexbox'>
<div class='button back back_pos'>
<i class='fa fa-arrow-circle-left'/>
</div>
<div class='login-picture'>
<t t-if='!widget.pos.get_cashier().id'>
<i class='fa fa-camera'></i>
</t>
<t t-if='widget.pos.get_cashier().id'>
<img t-att-src='widget.user_icon_url(widget.pos.get_cashier().id)' />
</t>
</div>
<div><h2><t t-esc="widget.pos.get_cashier().name"/></h2></div>
<div class="password_input">
<input class='user_password' name='password' placeholder='Password' type="password"/>
</div>
<div><span class="pos_invalid_password"/></div>
<div class='button login pos_login'>
<i class="fa fa-arrow-circle-right" aria-hidden="true"/>
</div>
</div>
</div>
</t>
</templates>

21
pos_lock_session/views/pos_lock.xml

@ -0,0 +1,21 @@
<odoo>
<data>
<record id="view_pos_quick_payment_config_form" model="ir.ui.view">
<field name="name">pos.config.form.view</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="arch" type="xml">
<group name="features" position="after">
<group name="session_lock" string="Screen Lock">
<group>
<field name="pos_lock"/>
</group>
<group>
<field name="bg_color"/>
</group>
</group>
</group>
</field>
</record>
</data>
</odoo>

12
pos_lock_session/views/pos_templates.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/pos_lock_session/static/src/css/session_lock.css"/>
<script type="text/javascript" src="/pos_lock_session/static/src/js/unlock_screen.js"/>
<script type="text/javascript" src="/pos_lock_session/static/src/js/session_lock.js"/>
</xpath>
</template>
</data>
</odoo>
Loading…
Cancel
Save