Browse Source

[IMP] add autologout to pos_quick_logout

[IMP] it's better to launch timeout fonction with start
pull/455/head
Invitu 7 years ago
committed by Iván Todorovich
parent
commit
f186b9b540
  1. 1
      pos_quick_logout/__init__.py
  2. 1
      pos_quick_logout/__openerp__.py
  3. 2
      pos_quick_logout/models/__init__.py
  4. 11
      pos_quick_logout/models/pos_quick_logout.py
  5. 27
      pos_quick_logout/static/src/js/pos_quick_logout.js
  6. 13
      pos_quick_logout/views/pos_quick_logout_view.xml

1
pos_quick_logout/__init__.py

@ -1 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import models

1
pos_quick_logout/__openerp__.py

@ -15,6 +15,7 @@
'point_of_sale', 'point_of_sale',
], ],
'data': [ 'data': [
'views/pos_quick_logout_view.xml',
'static/src/xml/templates.xml', 'static/src/xml/templates.xml',
], ],
'qweb': [ 'qweb': [

2
pos_quick_logout/models/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
import pos_quick_logout

11
pos_quick_logout/models/pos_quick_logout.py

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from odoo import models, api, fields, exceptions
class PosConfig(models.Model):
_inherit = 'pos.config'
logout_timeout = fields.Integer(
default=10, string='Logout Timeout',
help='Time out for automatic logout for sessions in this POS')

27
pos_quick_logout/static/src/js/pos_quick_logout.js

@ -8,11 +8,38 @@ odoo.define('pos_quick_logout.pos_quick_logout', function (require) {
"use strict"; "use strict";
var chrome = require('point_of_sale.chrome'); var chrome = require('point_of_sale.chrome');
var core = require('web.core');
/* ******************************************************** /* ********************************************************
chrome.Chrome chrome.Chrome
******************************************************** */ ******************************************************** */
chrome.Chrome.include({ chrome.Chrome.include({
start: function(){
var self = this;
this._super();
this.timer = false;
this.idletimeout();
},
idletimeout: function() {
var self = this;
$(document).bind('mousemove keypress mousedown click scroll', function(){
self.resetTimer();
});
},
logout: function() {
var self = this;
if (self.widget.username) {
self.pos.set_cashier(self.pos.user);
self.widget.username.renderElement();
};
},
resetTimer: function() {
var self = this;
clearTimeout(this.timer);
this.timer = setTimeout(function(){
self.logout();
}, self.pos.config.logout_timeout * 1000); // time is in milliseconds
},
renderElement: function(){ renderElement: function(){
this._super(); this._super();
var self = this; var self = this;

13
pos_quick_logout/views/pos_quick_logout_view.xml

@ -0,0 +1,13 @@
<odoo>
<record id="view_pos_config_view_form_quick_logout" model="ir.ui.view">
<field name="name">pos.config.form.quick.logout</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="priority" eval="30"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='iface_big_scrollbars']" position="after">
<field name="logout_timeout"/>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save