diff --git a/pos_check_session_state/__init__.py b/pos_check_session_state/__init__.py new file mode 100644 index 00000000..743db2e9 --- /dev/null +++ b/pos_check_session_state/__init__.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Check Session State module for OpenERP +# Copyright (C) 2015 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License 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 . +# +############################################################################## diff --git a/pos_check_session_state/__openerp__.py b/pos_check_session_state/__openerp__.py new file mode 100644 index 00000000..01fdee37 --- /dev/null +++ b/pos_check_session_state/__openerp__.py @@ -0,0 +1,68 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Point Of Sale - Check Session State module for OpenERP +# Copyright (C) 2015 GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License 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 . +# +############################################################################## + +{ + 'name': 'Point Of Sale - Check Session State', + 'summary': 'Check if the session state is still opened', + 'version': '0.1', + 'category': 'Point Of Sale', + 'description': """ +Check if the session state is still opened +========================================== + +Context: +-------- +In Point Of Sale module, the front-end works offline, so all datas are +loaded at the beginning. +At the end of the session, if user do not close the window, it will be +possible to create new pos order on a closed session, generating errors. + +Functionality: +-------------- + * This module prevent the possility to create a pos order via the front + end PoS UI, when session is closed. + * The session state is checked every 10 seconds. If the state of the + session is not opened, a blocking pop up is displayed, and user has to + reload the current page. + +Copyright, Authors and Licence: +------------------------------- + * Copyright: 2015, GRAP: Groupement Régional Alimentaire de Proximité; + * Author: + * Sylvain LE GAL (https://twitter.com/legalsylvain); + * Licence: AGPL-3 (http://www.gnu.org/licenses/);""", + 'author': "GRAP,Odoo Community Association (OCA)", + 'website': 'http://www.grap.coop', + 'license': 'AGPL-3', + 'depends': [ + 'point_of_sale', + ], + 'qweb': [ + 'static/src/xml/pos_check_session_state.xml', + ], + 'js': [ + 'static/src/js/pos_check_session_state.js', + ], + 'css': [ + 'static/src/css/pos_check_session_state.css', + ], +} diff --git a/pos_check_session_state/i18n/fr.po b/pos_check_session_state/i18n/fr.po new file mode 100644 index 00000000..f55a6f39 --- /dev/null +++ b/pos_check_session_state/i18n/fr.po @@ -0,0 +1,31 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * pos_check_session_state +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-27 12:47+0000\n" +"PO-Revision-Date: 2015-06-27 12:47+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_check_session_state +#. openerp-web +#: code:addons/pos_check_session_state/static/src/xml/pos_check_session_state.xml:29 +#, python-format +msgid "Please close the current Point Of Sale Window and open it again to use a correct session." +msgstr "Veuillez fermer la fenêtre courante du point de vente et en ouvrir une autre, afin d'utiliser une session correcte." + +#. module: pos_check_session_state +#. openerp-web +#: code:addons/pos_check_session_state/static/src/xml/pos_check_session_state.xml:28 +#, python-format +msgid "Sorry, the session you're working on is now closing or closed." +msgstr "Désolé, la session sur laquelle vous travaillez est désormais en cours de clôture, ou clôturée." + diff --git a/pos_check_session_state/static/src/img/icon.png b/pos_check_session_state/static/src/img/icon.png new file mode 100644 index 00000000..a9e1244d Binary files /dev/null and b/pos_check_session_state/static/src/img/icon.png differ diff --git a/pos_check_session_state/static/src/js/pos_check_session_state.js b/pos_check_session_state/static/src/js/pos_check_session_state.js new file mode 100644 index 00000000..ff6fe8a2 --- /dev/null +++ b/pos_check_session_state/static/src/js/pos_check_session_state.js @@ -0,0 +1,69 @@ +/****************************************************************************** + Point Of Sale - Check Session State module for Odoo + Copyright (C) 2015-Today GRAP (http://www.grap.coop) + @author Sylvain LE GAL (https://twitter.com/legalsylvain) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License 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 . +******************************************************************************/ + +openerp.pos_check_session_state = function (instance) { + module = instance.point_of_sale; + + /* + Define : New ErrorClosedSessionPopupWidget Widget. + This pop up will be shown if the current pos.session of the PoS is not + in an 'open' state; + The check will be down each 10 seconds; + */ + module.ErrorClosedSessionPopupWidget = module.ErrorPopupWidget.extend({ + template:'ErrorClosedSessionPopupWidget', + + check_session_frequency: 2000, + session_name: '', + + init: function(parent, options) { + var self = this; + this._super(parent,options); + this.intervalID = setInterval(function() { + var loaded = self.pos.fetch('pos.session', ['name','state'], [['id', '=', self.pos.get('pos_session').id]]) + .then(function(sessions){ +// if (sessions[0]['state'] != 'opened') { + if (true){ + self.session_name = sessions[0]['name']; + self.renderElement(); + self.pos_widget.screen_selector.show_popup('error-closed-session'); + clearInterval(self.intervalID); + } + }) + }, this.check_session_frequency); + }, + }); + + /* + Overload : PosWidget to include ErrorClosedSessionPopupWidget inside. + */ + module.PosWidget = module.PosWidget.extend({ + build_widgets: function(){ + this._super(); + this.error_closed_session_popup = new module.ErrorClosedSessionPopupWidget(this, {}); + this.error_closed_session_popup.appendTo($('.point-of-sale')); + this.screen_selector.popup_set['error-closed-session'] = this.error_closed_session_popup; + + // Hide the popup because all pop up are displayed at the + // beginning by default + this.error_closed_session_popup.hide(); + }, + }); + +}; diff --git a/pos_check_session_state/static/src/xml/pos_check_session_state.xml b/pos_check_session_state/static/src/xml/pos_check_session_state.xml new file mode 100644 index 00000000..f784531c --- /dev/null +++ b/pos_check_session_state/static/src/xml/pos_check_session_state.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +