Browse Source
[ADD] new module pos_check_session_state to avoid PoS users use closed sessions;
pull/34/head^2
[ADD] new module pos_check_session_state to avoid PoS users use closed sessions;
pull/34/head^2
6 changed files with 224 additions and 0 deletions
-
21pos_check_session_state/__init__.py
-
68pos_check_session_state/__openerp__.py
-
31pos_check_session_state/i18n/fr.po
-
BINpos_check_session_state/static/src/img/icon.png
-
69pos_check_session_state/static/src/js/pos_check_session_state.js
-
35pos_check_session_state/static/src/xml/pos_check_session_state.xml
@ -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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
@ -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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
{ |
|||
'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', |
|||
], |
|||
} |
@ -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." |
|||
|
After Width: 64 | Height: 64 | Size: 4.1 KiB |
@ -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 <http://www.gnu.org/licenses/>.
|
|||
******************************************************************************/ |
|||
|
|||
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(); |
|||
}, |
|||
}); |
|||
|
|||
}; |
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!-- ********************************************************************** --> |
|||
<!--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 <http://www.gnu.org/licenses/>. --> |
|||
<!-- ********************************************************************** --> |
|||
<templates id="template" xml:space="preserve"> |
|||
|
|||
<t t-name="ErrorClosedSessionPopupWidget"> |
|||
<div class="modal-dialog"> |
|||
<div class="popup"> |
|||
<h1> |
|||
<t t-esc="widget.session_name" /> |
|||
</h1> |
|||
<p> |
|||
Sorry, the session you're working on is now closing or closed. <br /> |
|||
Please close the current Point Of Sale Window and open it again to use a correct session.</p> |
|||
</div> |
|||
</div> |
|||
</t> |
|||
|
|||
</templates> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue