diff --git a/pos_logout/README.rst b/pos_logout/README.rst new file mode 100644 index 0000000000..3d9f24c46c --- /dev/null +++ b/pos_logout/README.rst @@ -0,0 +1,27 @@ +.. image:: https://itpp.dev/images/infinity-readme.png + :alt: Tested and maintained by IT Projects Labs + :target: https://itpp.dev + +================= + Lock POS Screen +================= + +Automatically lock pos on inactivity + +Questions? +========== + +To get an assistance on this module contact us by email :arrow_right: help@itpp.dev + +Contributors +============ +* `Gabbasov Dinar `__ +* `Kolushov Alexandr `__ +* `Kildebekov Anvar `__ + +=================== + +Odoo Apps Store: https://apps.odoo.com/apps/modules/13.0/pos_logout/ + + +Tested on `Odoo 13.0 `_ diff --git a/pos_logout/__init__.py b/pos_logout/__init__.py new file mode 100644 index 0000000000..1d99e04b62 --- /dev/null +++ b/pos_logout/__init__.py @@ -0,0 +1,3 @@ +# License MIT (https://opensource.org/licenses/MIT). + +from . import models diff --git a/pos_logout/__manifest__.py b/pos_logout/__manifest__.py new file mode 100644 index 0000000000..0f2fc0e14e --- /dev/null +++ b/pos_logout/__manifest__.py @@ -0,0 +1,31 @@ +# Copyright 2017 Artyom Losev +# Copyright 2017-2018 Ilmir Karamov +# Copyright 2018 Kolushov Alexandr +# Copyright 2020 Almas Giniatullin +# Copyright 2021 Denis Mudarisov +# License MIT (https://opensource.org/licenses/MIT). +{ + "name": """Lock POS Screen""", + "summary": """Automatically lock pos on inactivity""", + "category": "Point of Sale", + # "live_test_url": "http://apps.it-projects.info/shop/product/pos-logout?version=13.0", + "images": ["images/pos_logout_main.png"], + "version": "14.0.2.0.0", + "application": False, + "author": "IT-Projects LLC, Dinar Gabbasov", + "support": "apps@itpp.dev", + "website": "https://github.com/itpp-labs/pos-addons#readme", + "license": "Other OSI approved licence", # MIT + "price": 20.00, + "currency": "EUR", + "depends": ["point_of_sale"], + "external_dependencies": {"python": [], "bin": []}, + "data": ["views/pos_logout.xml"], + "qweb": ["static/src/xml/pos.xml"], + "demo": [], + "post_load": None, + "pre_init_hook": None, + "post_init_hook": None, + "auto_install": False, + "installable": True, +} diff --git a/pos_logout/doc/changelog.rst b/pos_logout/doc/changelog.rst new file mode 100644 index 0000000000..22a984d0fe --- /dev/null +++ b/pos_logout/doc/changelog.rst @@ -0,0 +1,9 @@ +`2.0.0` +------- + +**Improvement:** removed `pos_pin` dependency due to existing functionality + +`1.0.0` +------- + +- Init version diff --git a/pos_logout/doc/index.rst b/pos_logout/doc/index.rst new file mode 100644 index 0000000000..6fa3ac3fdc --- /dev/null +++ b/pos_logout/doc/index.rst @@ -0,0 +1,48 @@ +================= + Lock POS Screen +================= + +Installation +============ + +* `Install `__ this module in a usual way + +Configuration +============= + +* Open menu ``[[ Point of Sale ]] >> Configuration >> Point of Sale`` +* Choose the POS where you need the ability to lock the screen +* Enable `Login with Employees` and set `Allowed Employees` or you can leave this field blank + +Setting auto-locking interval +----------------------------- + +The last activity interval to activate the automatic screen lock. Zero if auto-locking is not needed + +* Open menu ``[[ Point of Sale ]] >> Configuration >> Point of Sale`` + + * Open POS configuration form + * Click ``[Edit]`` + * Input in **Screen Auto-lock** a number of seconds before auto-locking. Zero if auto-locking is not needed + * Click ``[Save]`` + +Setting **Badge ID** and/or **Security PIN** for login the POS +-------------------------------------------------------------- + +* Go to ``Employees`` + + * Open user form + * Open **HR Settings** tab + * Set **Badge ID** and/or **Security PIN** + +Usage +===== + +The last activity interval to activate the automatic screen lock. Zero if autolocking is not needed + +* Open menu ``[[ Point of Sale ]] >> Configuration >> Point of Sale`` + + * Open POS configuration form + * Click ``[Edit]`` + * Input in **Autolock** a number of seconds before autolocking. Zero if autolocking is not needed + * Click ``[Save]`` diff --git a/pos_logout/i18n/pos_logout.pot b/pos_logout/i18n/pos_logout.pot new file mode 100644 index 0000000000..107fe18f7f --- /dev/null +++ b/pos_logout/i18n/pos_logout.pot @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_logout +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_logout +#: model:ir.model,name:pos_logout.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_logout +#: model:ir.model.fields,field_description:pos_logout.field_pos_config__logout_interval +msgid "Screen Autolock" +msgstr "" + +#. module: pos_logout +#. openerp-web +#: code:addons/pos_logout/static/src/xml/pos.xml:18 +#, python-format +msgid "Tap to unlock..." +msgstr "" + +#. module: pos_logout +#: model:ir.model.fields,help:pos_logout.field_pos_config__logout_interval +#: model_terms:ir.ui.view,arch_db:pos_logout.view_pos_config_form +msgid "The last activity interval to activate the automatic screen lock. Zero if autolocking is not needed" +msgstr "" + diff --git a/pos_logout/images/pos_logout_main.png b/pos_logout/images/pos_logout_main.png new file mode 100644 index 0000000000..30d1c52195 Binary files /dev/null and b/pos_logout/images/pos_logout_main.png differ diff --git a/pos_logout/models/__init__.py b/pos_logout/models/__init__.py new file mode 100644 index 0000000000..820c91481b --- /dev/null +++ b/pos_logout/models/__init__.py @@ -0,0 +1,3 @@ +# License MIT (https://opensource.org/licenses/MIT). + +from . import logout_config diff --git a/pos_logout/models/logout_config.py b/pos_logout/models/logout_config.py new file mode 100644 index 0000000000..3aa1b9c7d8 --- /dev/null +++ b/pos_logout/models/logout_config.py @@ -0,0 +1,14 @@ +# Copyright 2018 Kolushov Alexandr +# License MIT (https://opensource.org/licenses/MIT). + +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + logout_interval = fields.Integer( + string="Screen Auto-lock", + default=0, + help="The last activity interval to activate the automatic screen lock. Zero if autolocking is not needed", + ) diff --git a/pos_logout/static/description/icon.png b/pos_logout/static/description/icon.png new file mode 100644 index 0000000000..8a058284ed Binary files /dev/null and b/pos_logout/static/description/icon.png differ diff --git a/pos_logout/static/description/index.html b/pos_logout/static/description/index.html new file mode 100644 index 0000000000..fe274b4d36 --- /dev/null +++ b/pos_logout/static/description/index.html @@ -0,0 +1,78 @@ +
+
+
+

Lock POS Screen

+

Automatic logout by a set timer

+
+
+
+ +
+
+
+

+

+ Key features: +
    +
  • + + Set auto-lock time +
  • +
+
+

+
+
+
+ +
+ +
+
+
+

Need our service?

+

Contact us by email

+ +
+
+
+
+ Tested on Odoo
13.0 community +
+
+ Tested on Odoo
13.0 enterprise +
+
+
+
+
diff --git a/pos_logout/static/src/css/pos_logout.css b/pos_logout/static/src/css/pos_logout.css new file mode 100644 index 0000000000..ede82c35ea --- /dev/null +++ b/pos_logout/static/src/css/pos_logout.css @@ -0,0 +1,25 @@ +.pos .popup-selection .exit { + position: absolute; + right: 0px; + top: 0; + padding: 15px; + cursor: pointer; + font-size: 30px; +} +.pos .modal-dialog.block { + background-color: rgba(85, 0, 0, 0.5); + cursor: pointer; +} +.pos .modal-dialog.block .popup-selection { + background-color: initial; + box-shadow: none; + height: 250px; + color: black; + font-size: 65px; +} +.pos .modal-dialog.block .popup-selection p { + margin: 0; +} +.pos .modal-dialog.block .popup-selection i { + font-size: 150px; +} diff --git a/pos_logout/static/src/js/chrome.js b/pos_logout/static/src/js/chrome.js new file mode 100644 index 0000000000..abc08d1821 --- /dev/null +++ b/pos_logout/static/src/js/chrome.js @@ -0,0 +1,33 @@ +/* Copyright 2017 Ivan Yelizariev + Copyright 2017 Artyom Losev + Copyright 2018 Kolushov Alexandr + Copyright 2020 Almas Giniatullin + License MIT (https://opensource.org/licenses/MIT). */ +odoo.define("pos_logout.chrome", function (require) { + "use strict"; + var chrome = require("point_of_sale.chrome"); + + chrome.Chrome.include({ + loading_hide: function () { + this._super(); + var self = this; + var set_logout_interval = function (time) { + time = time || self.pos.config.logout_interval * 1000; + if (time) { + self.pos.logout_timer = setTimeout(function () { + self.pos.gui.show_screen("login"); + }, time); + } + }; + if (this.pos.config.logout_interval) { + $(document).on("click", function (event) { + clearTimeout(self.pos.logout_timer); + set_logout_interval(); + }); + set_logout_interval(); + } + }, + }); + + return chrome; +}); diff --git a/pos_logout/static/src/js/tour.js b/pos_logout/static/src/js/tour.js new file mode 100644 index 0000000000..b518c19aa9 --- /dev/null +++ b/pos_logout/static/src/js/tour.js @@ -0,0 +1,73 @@ +/* Copyright 2018-2019 Kolushov Alexandr + * Copyright 2019 Kildebekov Anvar + * License MIT (https://opensource.org/licenses/MIT). */ + +odoo.define("pos_logout.tour", function (require) { + "use strict"; + + var tour = require("web_tour.tour"); + + function pos_opening() { + return [ + tour.stepUtils.showAppsMenuItem(), + { + trigger: + '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"], .oe_menu_toggler[data-menu-xmlid="point_of_sale.menu_point_root"]', + content: + "Ready to launch your point of sale? Click here.", + position: "right", + edition: "community", + }, + { + trigger: '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"]', + content: + "Ready to launch your point of sale? Click here.", + position: "bottom", + edition: "enterprise", + }, + { + trigger: ".o_pos_kanban button.oe_kanban_action_button", + content: + "

Click to start the point of sale interface. It runs on tablets, laptops, or industrial hardware.

Once the session launched, the system continues to run without an internet connection.

", + }, + { + trigger: ".pos:has(.loader:hidden)", + content: "waiting for loading to finish", + timeout: 20000, + run: function () { + // It's a check + }, + }, + { + content: "Switch to table or make dummy action", + trigger: + ".table:not(.oe_invisible .neworder-button), .order-button.selected", + }, + ]; + } + + function pos_closing() { + return [ + { + trigger: ".header-button", + content: "close the Point of Sale frontend", + }, + { + trigger: ".header-button, .close_button, .confirm", + content: "close the Point of Sale", + }, + { + content: "wait until backend is opened", + trigger: ".o_pos_kanban button.oe_kanban_action_button", + run: function () { + // No need to click on trigger + }, + }, + ]; + } + + var steps = []; + steps = steps.concat(pos_opening(), pos_closing()); + + tour.register("pos_logout_tour", {test: true, url: "/web"}, steps); +}); diff --git a/pos_logout/tests/__init__.py b/pos_logout/tests/__init__.py new file mode 100644 index 0000000000..7ea835c5f7 --- /dev/null +++ b/pos_logout/tests/__init__.py @@ -0,0 +1 @@ +from . import test_default diff --git a/pos_logout/tests/test_default.py b/pos_logout/tests/test_default.py new file mode 100644 index 0000000000..1dec0657c3 --- /dev/null +++ b/pos_logout/tests/test_default.py @@ -0,0 +1,27 @@ +# Copyright 2018 Gabbasov Dinar +# Copyright 2019 Kildebekov Anvar +# License MIT (https://opensource.org/licenses/MIT). + +import odoo.tests + + +@odoo.tests.common.at_install(True) +@odoo.tests.common.post_install(True) +class TestUi(odoo.tests.HttpCase): + def test_01_pos_is_loaded(self): + env = self.env + # From https://github.com/odoo/odoo/blob/48dafd5b2011cee966920f664a904de2e2715ae8/addons/point_of_sale/tests/test_frontend.py#L306-L310 + # needed because tests are run before the module is marked as + # installed. In js web will only load qweb coming from modules + # that are returned by the backend in module_boot. Without + # this you end up with js, css but no qweb. + env["ir.module.module"].search( + [("name", "=", "pos_logout")], limit=1 + ).state = "installed" + self.browser_js( + "/web", + "odoo.__DEBUG__.services['web_tour.tour']" ".run('pos_logout_tour')", + "odoo.__DEBUG__.services['web_tour.tour']" ".tours.pos_logout_tour.ready", + login="admin", + timeout=240, + ) diff --git a/pos_logout/views/pos_logout.xml b/pos_logout/views/pos_logout.xml new file mode 100644 index 0000000000..eba8eac2e5 --- /dev/null +++ b/pos_logout/views/pos_logout.xml @@ -0,0 +1,49 @@ + + + +