Browse Source

[MIG] pos_quick_logout: Migration to 12.0

pull/455/head
Iván Todorovich 5 years ago
parent
commit
a4f3f8cf99
  1. 67
      pos_quick_logout/README.rst
  2. 1
      pos_quick_logout/__init__.py
  3. 6
      pos_quick_logout/__manifest__.py
  4. 1
      pos_quick_logout/models/__init__.py
  5. 1
      pos_quick_logout/models/pos_config.py
  6. 2
      pos_quick_logout/readme/CONTRIBUTORS.rst
  7. 19
      pos_quick_logout/readme/DESCRIPTION.rst
  8. 32
      pos_quick_logout/static/src/js/pos_quick_logout.js
  9. 8
      pos_quick_logout/views/assets.xml
  10. 19
      pos_quick_logout/views/pos_config_view.xml

67
pos_quick_logout/README.rst

@ -1,67 +0,0 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
==================
PoS - Quick Logout
==================
This module was written to extend the functionality of Odoo Point Of Sale about
changing of cashier.
This module add a simple button 'Log Out' available in Point Of Sale Front End
UI. This button is available when the cashier is not the initial user logged in
Odoo. It allows to log out quickly, wihout selecting again the user in the
list. This module is useful for users that use regularly the change of cashier,
especialy with 'pos_access_right', when users doesn't have the right to do some
actions like set discount, change unit price, ...
Implemented Features
--------------------
* By default, the header is unchanged
.. image:: /pos_quick_logout/static/description/cashier_user_identical.png
* If the cashier changed, and is not the user logged in Odoo, the extra button appears
.. image:: /pos_quick_logout/static/description/cashier_user_different.png
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/184/9.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/pos/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Sylvain LE GAL <https://twitter.com/legalsylvain>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

1
pos_quick_logout/__init__.py

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

6
pos_quick_logout/__manifest__.py

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>) # Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Point of Sale - Quick Logout', 'name': 'Point of Sale - Quick Logout',
'version': '10.0.1.0.0',
'version': '12.0.1.0.0',
'category': 'Point Of Sale', 'category': 'Point Of Sale',
'summary': 'Allow PoS user to logout quickly after user changed', 'summary': 'Allow PoS user to logout quickly after user changed',
'license': 'AGPL-3', 'license': 'AGPL-3',
@ -17,7 +15,7 @@
], ],
'data': [ 'data': [
'views/pos_config_view.xml', 'views/pos_config_view.xml',
'static/src/xml/templates.xml',
'views/assets.xml',
], ],
'qweb': [ 'qweb': [
'static/src/xml/pos_quick_logout.xml', 'static/src/xml/pos_quick_logout.xml',

1
pos_quick_logout/models/__init__.py

@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import pos_config from . import pos_config

1
pos_quick_logout/models/pos_config.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from odoo import models, fields from odoo import models, fields

2
pos_quick_logout/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
* Druidoo <https://www.druidoo.io>

19
pos_quick_logout/readme/DESCRIPTION.rst

@ -0,0 +1,19 @@
This module was written to extend the functionality of Odoo Point Of Sale about
changing of cashier.
This module add a simple button 'Log Out' available in Point Of Sale Front End
UI. This button is available when the cashier is not the initial user logged in
Odoo. It allows to log out quickly, wihout selecting again the user in the
list. This module is useful for users that use regularly the change of cashier,
especialy with 'pos_access_right', when users doesn't have the right to do some
actions like set discount, change unit price, ...
* By default, the header is unchanged
.. image:: ../static/description/cashier_user_identical.png
* If the cashier changed, and is not the user logged in Odoo, the extra button appears
.. image:: ../static/description/cashier_user_different.png

32
pos_quick_logout/static/src/js/pos_quick_logout.js

@ -1,20 +1,20 @@
/* /*
Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>) Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
Copyright (C) 2019-Today: Druidoo (<https://www.druidoo.io>)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/ */
odoo.define('pos_quick_logout.pos_quick_logout', function (require) {
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'); var core = require('web.core');
/* ********************************************************
chrome.Chrome
******************************************************** */
/* ********************************************************
chrome.Chrome
******************************************************** */
chrome.Chrome.include({ chrome.Chrome.include({
start: function(){
start: function() {
var self = this; var self = this;
this._super(); this._super();
this.timer = false; this.timer = false;
@ -22,7 +22,7 @@ chrome.Chrome
}, },
idletimeout: function() { idletimeout: function() {
var self = this; var self = this;
$(document).bind('mousemove keypress mousedown click scroll', function(){
$(document).bind('mousemove keypress mousedown click scroll', function() {
self.resetTimer(); self.resetTimer();
}); });
}, },
@ -36,29 +36,31 @@ chrome.Chrome
resetTimer: function() { resetTimer: function() {
var self = this; var self = this;
clearTimeout(this.timer); clearTimeout(this.timer);
if (self.pos.config && self.pos.config.logout_timeout) {
this.timer = setTimeout(function(){ this.timer = setTimeout(function(){
self.logout(); self.logout();
}, self.pos.config.logout_timeout * 1000); }, self.pos.config.logout_timeout * 1000);
}
}, },
renderElement: function(){
renderElement: function() {
this._super(); this._super();
var self = this; var self = this;
this.$('#pos-quick-logout').click(function(){
this.$('#pos-quick-logout').click(function() {
self.pos.set_cashier(self.pos.user); self.pos.set_cashier(self.pos.user);
self.widget.username.renderElement(); self.widget.username.renderElement();
}); });
} }
}); });
/* ********************************************************
chrome.Chrome
******************************************************** */
/* ********************************************************
chrome.Chrome
******************************************************** */
chrome.UsernameWidget.include({ chrome.UsernameWidget.include({
renderElement: function(){
renderElement: function() {
this._super(); this._super();
if (this.pos.user.id === this.pos.get_cashier().id){
if (this.pos.user.id === this.pos.get_cashier().id) {
$('#pos-quick-logout').hide(); $('#pos-quick-logout').hide();
}else{
} else {
$('#pos-quick-logout').show(); $('#pos-quick-logout').show();
} }
} }

8
pos_quick_logout/static/src/xml/templates.xml → pos_quick_logout/views/assets.xml

@ -6,12 +6,16 @@
--> -->
<odoo> <odoo>
<template id="assets_frontend" inherit_id="point_of_sale.assets"> <template id="assets_frontend" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside"> <xpath expr="." position="inside">
<script type="text/javascript" src="/pos_quick_logout/static/src/js/pos_quick_logout.js"/>
<script type="text/javascript"
src="/pos_quick_logout/static/src/js/pos_quick_logout.js"/>
</xpath> </xpath>
<xpath expr="//link[@id='pos-stylesheet']" position="after"> <xpath expr="//link[@id='pos-stylesheet']" position="after">
<link rel="stylesheet" href="/pos_quick_logout/static/src/css/pos_quick_logout.css" />
<link rel="stylesheet"
href="/pos_quick_logout/static/src/css/pos_quick_logout.css" />
</xpath> </xpath>
</template> </template>
</odoo> </odoo>

19
pos_quick_logout/views/pos_config_view.xml

@ -1,13 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="view_pos_config_view_form_quick_logout" model="ir.ui.view"> <record id="view_pos_config_view_form_quick_logout" model="ir.ui.view">
<field name="name">pos.config.form.quick.logout</field> <field name="name">pos.config.form.quick.logout</field>
<field name="model">pos.config</field> <field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="priority" eval="30"/> <field name="priority" eval="30"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='iface_big_scrollbars']" position="after">
<field name="logout_timeout"/>
<xpath expr="//div[hasclass('o_settings_container')][2]"
position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label">Logout Timeout</span>
<div class="content-group mt16">
<field name="logout_timeout" colspan="4"
nolabel="1"/>
</div>
</div>
</div>
</xpath> </xpath>
</field> </field>
</record> </record>
</odoo> </odoo>
Loading…
Cancel
Save