Browse Source

commit inicial

Rodney Elpidio Enciso Arias 6 years ago
commit
c8cf6e38fb

+ 38 - 0
README.rst

@@ -0,0 +1,38 @@
+.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
+   :target: https://www.gnu.org/licenses/agpl
+   :alt: License: AGPL-3
+
+===================================================
+Prevent undesired window close in the Point of Sale
+===================================================
+
+Context
+-------
+
+This module extends the functionality of Point of Sale Module to display
+an extra pop up confirmation, in case of the user try to close the current
+Point of Sale window.
+
+It is usefull in a context where there are a lot of customers, to
+prevent manipulation error that force user to reload all the Point of sale,
+specially if users are using tactile screen.
+
+This module disables too the "back" button in the point of sale.
+
+.. figure:: /pos_confirm_window_close/static/description/pos_confirmation_close.png
+   :width: 800 px
+
+Credits
+=======
+
+Contributors
+------------
+
+* Sylvain LE GAL (https://www.twitter.com/legalsylvain)
+
+Funders
+-------
+
+The development of this module has been financially supported by:
+
+* GRAP, Groupement Régional Alimentaire de Proximité (http://www.grap.coop)

+ 1 - 0
__init__.py

@@ -0,0 +1 @@
+# coding: utf-8

BIN
__init__.pyc


+ 21 - 0
__openerp__.py

@@ -0,0 +1,21 @@
+# coding: utf-8
+# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
+# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+{
+    'name': 'Point Of Sale - Confirm Window Close',
+    'summary': 'Prevent undesired window close in the Point of Sale',
+    'version': '8.0.1.0.0',
+    'category': 'Point Of Sale',
+    'author': "GRAP",
+    'website': 'http://www.grap.coop',
+    'license': 'AGPL-3',
+    'depends': [
+        'point_of_sale',
+    ],
+    'data': [
+        'views/templates.xml',
+    ],
+    'installable': True,
+}

+ 24 - 0
i18n/fr.po

@@ -0,0 +1,24 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+#	* pos_confirm_window_close
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2018-02-28 15:56+0000\n"
+"PO-Revision-Date: 2018-02-28 15:56+0000\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_confirm_window_close
+#. openerp-web
+#: code:addons/pos_confirm_window_close/static/src/js/pos_confirm_window_close.js:21
+#, python-format
+msgid "You could have unsaved data in this window. Do you really want to leave?"
+msgstr "Vous pourriez avoir des données non sauvegardées dans la fenêtre, voulez-vous réellement quitter le point de vente ?"
+

BIN
static/description/pos_confirmation_close.png


+ 35 - 0
static/src/js/pos_confirm_window_close.js

@@ -0,0 +1,35 @@
+/*
+Copyright (C) 2017-Today GRAP (http://www.grap.coop)
+@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
+License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+*/
+
+"use strict";
+
+openerp.pos_confirm_window_close = function(instance){
+    var module = instance.point_of_sale;
+
+    module.PosWidget = module.PosWidget.extend({
+        start: function() {
+            // Prevent History back
+            window.addEventListener("popstate", function() {
+                history.pushState(null, null, document.URL);
+            });
+
+            // Prevent closing window
+            window.addEventListener("beforeunload", function(e) {
+                var confirmationMessage = instance.web._t(
+                    "You could have unsaved data in this window. " +
+                    "Do you really want to leave?");
+                e.returnValue = confirmationMessage;
+                return confirmationMessage;
+            });
+            return this._super();
+        },
+    });
+};
+
+
+
+
+

+ 16 - 0
views/templates.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (C) 2015-Today GRAP (http://www.grap.coop)
+@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
+ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+-->
+
+<openerp><data>
+
+    <template id="assets_pos_confirm_window_close" name="pos_confirm_window_close" inherit_id="point_of_sale.index">
+        <xpath expr="." position="inside">
+            <script type="text/javascript" src="/pos_confirm_window_close/static/src/js/pos_confirm_window_close.js"></script>
+        </xpath>
+    </template>
+
+</data></openerp>