Commit e81534a3 by Damien Moulard

prevent closing pos if ongoing order

parent ce8930fb
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
Personnalisation de la popup d'erreur "codebarre non reconnu" :\n Personnalisation de la popup d'erreur "codebarre non reconnu" :\n
- Faire clignoter la popup d'erreur quand le codebarre n'est pas reconnu - Faire clignoter la popup d'erreur quand le codebarre n'est pas reconnu
- Jouer le son d'erreur plusieurs fois - Jouer le son d'erreur plusieurs fois
- [FONCTION COMMENTEE] Afficher dans la popup le dernier produit scanné - [FONCTION DÉSACTIVÉE] Afficher dans la popup le dernier produit scanné\n
Bloquer ou non la fermeture d'une session de caisse s'il reste une commande en cours (configurable pour chaque caisse)
""", """,
'author': "fracolo", 'author': "fracolo",
......
...@@ -21,6 +21,11 @@ msgid "Reload on prices change" ...@@ -21,6 +21,11 @@ msgid "Reload on prices change"
msgstr "Rechargement si des prix changent" msgstr "Rechargement si des prix changent"
#. module: lacagette_custom_pos #. module: lacagette_custom_pos
#: model:ir.model.fields,field_description:lacagette_custom_pos.field_pos_config__can_close_pos_with_ongoing_order
msgid "Allow or not closing a pos session in case of ongoing order"
msgstr "Autoriser ou non la fermeture d'une session de caisse s'il reste une commande en cours"
#. module: lacagette_custom_pos
#. openerp-web #. openerp-web
#: code:lacagette_addons/lacagette_custom_pos/static/src/js/screens.js:73 #: code:lacagette_addons/lacagette_custom_pos/static/src/js/screens.js:73
#, python-format #, python-format
......
...@@ -6,4 +6,8 @@ class PosConfig(models.Model): ...@@ -6,4 +6,8 @@ class PosConfig(models.Model):
reload_on_prices_change = fields.Boolean( reload_on_prices_change = fields.Boolean(
string="Reload on prices change", string="Reload on prices change",
default=False) default=False)
\ No newline at end of file
can_close_pos_with_ongoing_order = fields.Boolean(
string="Allow closing a pos session in case of ongoing order",
default=True)
\ No newline at end of file
...@@ -9,8 +9,9 @@ odoo.define("lacagette_custom_pos.screens", function (require) { ...@@ -9,8 +9,9 @@ odoo.define("lacagette_custom_pos.screens", function (require) {
var _t = core._t; var _t = core._t;
const interval = 60 * 60 * 1000; // used for last_price_change call const interval = 60 * 60 * 1000; // used for last_price_change call
var reload_on_prices_change = false; var reload_on_prices_change = false;
models.load_fields("pos.config", ['reload_on_prices_change']); models.load_fields("pos.config", ['reload_on_prices_change', 'can_cclose_pos_with_ongoing_order']);
var close_button_action_setup = false;
const update_last_price_change_data = async function () { const update_last_price_change_data = async function () {
/* /*
Ask odoo server data about last prices change Ask odoo server data about last prices change
...@@ -130,4 +131,43 @@ odoo.define("lacagette_custom_pos.screens", function (require) { ...@@ -130,4 +131,43 @@ odoo.define("lacagette_custom_pos.screens", function (require) {
} }
}); });
screens.ScreenWidget.include({
init: function(parent,options){
this._super(parent,options);
/*
* If activated in this pos session, prevent closing the session if there is an ongoing order.
* This is a hacky DOM manipulation: the user can technically close the session if he closes the popup and press 'Close' again in less than 2s.
* But this is very unlikely.
*
* ScreenWidget is a base widget extended by many others, we do this here to be sure this code is called...
*/
if (close_button_action_setup === false) {
// ... but we need to make sure it is called only once
close_button_action_setup = true;
if (this.pos.config.can_close_pos_with_ongoing_order === false) {
let header_nodes = document.querySelectorAll(".pos-topheader .pos-rightheader div");
let close_button_div = header_nodes[header_nodes.length- 1];
let self = this;
close_button_div.addEventListener("click", function(e) {
let order = self.pos.get_order();
if (!order.is_empty()) {
if (close_button_div.classList.contains("confirm")) {
close_button_div.classList.remove("confirm");
close_button_div.textContent = _t('Close');
}
self.gui.show_popup("alert", {
'title': _t("Impossible de fermer la caisse"),
'body': _t("Des commandes sont encore en cours.")
});
}
});
}
}
},
});
}); });
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="cash_control" position="after"> <field name="cash_control" position="after">
<field name="reload_on_prices_change"/> <field name="reload_on_prices_change"/>
<field name="can_close_pos_with_ongoing_order"/>
</field> </field>
</field> </field>
</record> </record>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment