Browse Source

Merge 2b5251410b into 45a15ac568

pull/387/merge
Sylvain LE GAL 4 years ago
committed by GitHub
parent
commit
365aa7a1aa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 83
      pos_check_session_state/README.rst
  2. 1
      pos_check_session_state/__init__.py
  3. 28
      pos_check_session_state/__manifest__.py
  4. 61
      pos_check_session_state/i18n/fr.po
  5. 1
      pos_check_session_state/models/__init__.py
  6. 13
      pos_check_session_state/models/pos_config.py
  7. 4
      pos_check_session_state/readme/CONFIGURE.rst
  8. 1
      pos_check_session_state/readme/CONTRIBUTORS.rst
  9. 17
      pos_check_session_state/readme/DESCRIPTION.rst
  10. BIN
      pos_check_session_state/static/description/error_message.png
  11. BIN
      pos_check_session_state/static/description/icon.png
  12. BIN
      pos_check_session_state/static/description/pos_config_form.png
  13. 69
      pos_check_session_state/static/src/js/chrome.js
  14. 16
      pos_check_session_state/views/templates.xml
  15. 31
      pos_check_session_state/views/view_pos_config.xml

83
pos_check_session_state/README.rst

@ -0,0 +1,83 @@
===================================
Point Of Sale - Check Session State
===================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-grap%2Fgrap--odoo--incubator-lightgray.png?logo=github
:target: https://github.com/grap/grap-odoo-incubator/tree/8.0/pos_check_session_state
:alt: grap/grap-odoo-incubator
|badge1| |badge2| |badge3|
**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 minute by default. If the state of the
session is not opened, a blocking pop up is displayed, and user has to
reload the current page.
.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/8.0/pos_check_session_state/static/description/error_message.png
**Table of contents**
.. contents::
:local:
Configuration
=============
* Go to Point of Sale / Configuration / Point of Sales
* Open a PoS Config and set a frequency for the check
.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/8.0/pos_check_session_state/static/description/pos_config_form.png
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/grap/grap-odoo-incubator/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 <https://github.com/grap/grap-odoo-incubator/issues/new?body=module:%20pos_check_session_state%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* GRAP
Contributors
~~~~~~~~~~~~
* Sylvain LE GAL <https://twitter.com/legalsylvain>
Maintainers
~~~~~~~~~~~
This module is part of the `grap/grap-odoo-incubator <https://github.com/grap/grap-odoo-incubator/tree/8.0/pos_check_session_state>`_ project on GitHub.
You are welcome to contribute.

1
pos_check_session_state/__init__.py

@ -0,0 +1 @@
from . import models

28
pos_check_session_state/__manifest__.py

@ -0,0 +1,28 @@
# 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).
{
'name': 'Point Of Sale - Check Session State',
'summary': 'Check if the session state is still opened',
'version': '12.0.1.0.0',
'category': 'Point Of Sale',
'author': 'GRAP, Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/pos',
'license': 'AGPL-3',
'depends': [
'point_of_sale',
],
'data': [
'views/templates.xml',
'views/view_pos_config.xml',
],
'qweb': [
'static/src/xml/pos_check_session_state.xml',
],
'images': [
'static/description/error_message.png',
'static/description/pos_config_form.png',
],
'installable': True,
}

61
pos_check_session_state/i18n/fr.po

@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_check_session_state
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-09 20:22+0000\n"
"PO-Revision-Date: 2020-03-09 20:22+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
#: model:ir.model.fields,field_description:pos_check_session_state.field_pos_config__check_session_state_frequency
msgid "Frequency of Checking the State of the Session"
msgstr "Fréquence de vérification de l'état de la session"
#. module: pos_check_session_state
#. openerp-web
#: code:addons/pos_check_session_state/static/src/js/chrome.js:45
#, python-format
msgid "This PoS window will be closed and you'll have to open a new session."
msgstr "Cette fenêtre de point de vente sera fermée et vous devrez ouvrir une nouvelle sessions."
#. module: pos_check_session_state
#: model:ir.model,name:pos_check_session_state.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Paramétrage du point de vente"
#. module: pos_check_session_state
#. openerp-web
#: code:addons/pos_check_session_state/static/src/js/chrome.js:44
#, python-format
msgid "Session not opened : "
msgstr "Session non ouverte : "
#. module: pos_check_session_state
#. openerp-web
#: code:addons/pos_check_session_state/static/src/js/chrome.js:49
#, python-format
msgid "The session you're working on is closed : "
msgstr "La sessions sur laquelle vous travaillez est fermée : "
#. module: pos_check_session_state
#. openerp-web
#: code:addons/pos_check_session_state/static/src/js/chrome.js:47
#, python-format
msgid "The session you're working on is in closing control : "
msgstr "La session sur laquelle vous travaillez est en contrôle de fermeture : "
#. module: pos_check_session_state
#: model:ir.model.fields,help:pos_check_session_state.field_pos_config__check_session_state_frequency
#: model_terms:ir.ui.view,arch_db:pos_check_session_state.view_pos_config_form
msgid "The value is set in seconds."
msgstr "La valeur est définie en seconde."

1
pos_check_session_state/models/__init__.py

@ -0,0 +1 @@
from . import pos_config

13
pos_check_session_state/models/pos_config.py

@ -0,0 +1,13 @@
# Copyright (C) 2018 - 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).
from odoo import fields, models
class PosConfig(models.Model):
_inherit = 'pos.config'
check_session_state_frequency = fields.Integer(
string="Frequency of Checking the State of the Session",
default=60, help="The value is set in seconds.")

4
pos_check_session_state/readme/CONFIGURE.rst

@ -0,0 +1,4 @@
* Go to Point of Sale / Configuration / Point of Sales
* Open a PoS Config and set a frequency for the check
.. figure:: ../static/description/pos_config_form.png

1
pos_check_session_state/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>

17
pos_check_session_state/readme/DESCRIPTION.rst

@ -0,0 +1,17 @@
**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 doesn't 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 minute by default. If the state of the
session is not opened, a blocking pop up is displayed, and user has to
open a new session.
.. figure:: ../static/description/error_message.png

BIN
pos_check_session_state/static/description/error_message.png

After

Width: 493  |  Height: 396  |  Size: 20 KiB

BIN
pos_check_session_state/static/description/icon.png

After

Width: 64  |  Height: 64  |  Size: 4.1 KiB

BIN
pos_check_session_state/static/description/pos_config_form.png

After

Width: 1085  |  Height: 383  |  Size: 38 KiB

69
pos_check_session_state/static/src/js/chrome.js

@ -0,0 +1,69 @@
/*
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).
*/
odoo.define('pos_check_session_state.chrome', function (require){
"use strict";
var rpc = require('web.rpc');
var core = require('web.core');
var chrome = require('point_of_sale.chrome');
var _t = core._t;
/*
Overload build_widgets to add a check done every
check_session_state_frequency seconds, by a setInterval.
*/
chrome.Chrome.include({
build_widgets: function () {
var self = this;
var res = this._super.apply(this, arguments);
var frequency = self.pos.config.check_session_state_frequency * 1000;
self.intervalIDCheckSessionState = setInterval(function() {
self._check_session_state();
}, frequency);
return res;
},
_check_session_state: function() {
var self = this;
var params = {
model: 'pos.session',
method: 'search_read',
domain: [['id', '=', self.pos.pos_session.id]],
fields: ['state'],
};
rpc.query(params)
.then(function(sessions){
if (sessions[0].state !== 'opened') {
var title = _t("Session not opened : ") + self.pos.pos_session.name;
var body = _t("This PoS window will be closed and you'll have to open a new session.");
if ((sessions[0].state) !== 'closing_control') {
body = _t("The session you're working on is in closing control : ") + body;
} else {
body = _t("The session you're working on is closed : ") + body;
}
// warn user if current session is not opened
self.gui.show_popup('error', {
'title': title,
'body': body,
cancel: function(){
self.gui.close();
},
});
clearInterval(self.intervalIDCheckSessionState);
}
})
.fail(function(error, event){
// Prevent error if server is unreachable
event.preventDefault();
});
}
});
});

16
pos_check_session_state/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).
-->
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_check_session_state/static/src/js/chrome.js"/>
</xpath>
</template>
</odoo>

31
pos_check_session_state/views/view_pos_config.xml

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="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).
-->
<odoo>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='iface_big_scrollbars']/../.." position="after">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="check_session_state_frequency"/>
<div class="text-muted">
The value is set in seconds.
</div>
<div class="content-group mt16">
<field name="check_session_state_frequency" required="1"/>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save