diff --git a/pos_disable_payment/README.rst b/pos_disable_payment/README.rst new file mode 100644 index 0000000000..39bbe6848c --- /dev/null +++ b/pos_disable_payment/README.rst @@ -0,0 +1,38 @@ +.. image:: https://itpp.dev/images/infinity-readme.png + :alt: Tested and maintained by IT Projects Labs + :target: https://itpp.dev + +======================= +Disable payments in POS +======================= + +The module allows disable payments in POS. For example, it could be helpful to use POS only to get price of item by barcode + +Module allows directly in user settings: + +* disable create order line +* disable remove non-empty order +* disable discount button +* disable edit price button +* disable remove order line +* disable refunds + +Questions? +========== + +To get an assistance on this module contact us by email :arrow_right: help@itpp.dev + +Contributors +============ +* `Ivan Yelizariev `__ +* `Ilmir Karamov `__ +* `Dinar Gabbasov `__ + + +Further information +=================== + +Odoo Apps Store: https://apps.odoo.com/apps/modules/11.0/pos_disable_payment/ + + +Tested on `Odoo 11.0 `_ diff --git a/pos_disable_payment/__init__.py b/pos_disable_payment/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_disable_payment/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_disable_payment/__manifest__.py b/pos_disable_payment/__manifest__.py new file mode 100644 index 0000000000..74d739a275 --- /dev/null +++ b/pos_disable_payment/__manifest__.py @@ -0,0 +1,18 @@ +{ + "name": "Disable payments in POS", + "summary": "Control access to the POS payments", + "version": "12.0.1.0.0", + "author": "IT-Projects LLC, Ivan Yelizariev", + "license": "Other OSI approved licence", # MIT + "category": "Point Of Sale", + "live_test_url": "http://apps.it-projects.info/shop/product/pos-multi-session?version=11.0", + "support": "apps@itpp.dev", + "website": "https://yelizariev.github.io", + "depends": ["point_of_sale"], + "images": ["images/pos_payment_access.png"], + "price": 40.00, + "currency": "EUR", + "data": ["views.xml"], + "demo": ["views/assets_demo.xml"], + "installable": True, +} diff --git a/pos_disable_payment/doc/changelog.rst b/pos_disable_payment/doc/changelog.rst new file mode 100644 index 0000000000..506e40e166 --- /dev/null +++ b/pos_disable_payment/doc/changelog.rst @@ -0,0 +1,74 @@ +.. _changelog: + +Updates +======= + +`3.7.0` +------- + +**Improvement:** New option "Disable customer selection" +**Improvement:** Move the "Allow change Qty for kitchen orders" option to pos_disable_payment_restaurant module + +`3.6.1` +------- +- IMP: Compatibility with pos_restaurant_base module + +`2.6.1` +------- +- FIX: Option "Allow remove order line" didn't work correctly after the previous updates + +`2.6.0` +------- +- NEW: New option "Allow change Qty for kitchen orders" + +`2.5.0` +------- +- NEW: New option "Allow manual customer selecting" on user access rights + +`2.4.1` +------- +- FIX: Compatibility with pos_discount +- IMP: When unchecked "Allow remove order line", the delete button is disabled if qty of the line < = 0 + +`2.4.0` +------- +- NEW: Set disabled button as non-clickable instead of hiding + +`2.3.0` +------- +- NEW: New option "Allow refunds" on user access rights + +`2.2.4` +------- +- FIX: module didn't work with older odoo version in some context + +`2.2.3` +------- + +- IMP: Compatibility with the latest odoo version, tested on Odoo 10 e14ab697727d87773dbefba11453b9edca79fc68 + +`2.2.2` +------- + +- NEW: New option "Allow to create order line" for POS added to user access rights + +`2.1.2` +------- + +- FIX: "allow payments" checkbox was ignored after clicking "Set Customer" button + +`2.1.1` +------- + +- User POS settings now got two parameters (allow_decrease_amount and allow_delete_order_line) instead of only one +(allow_delete_order_line). If first parameter is FALSE than you cant set second one.. + +`2.0.0` +------- + +- Restrictions sets in User. + +`1.0.0` +------- + +- Restriction sets in POS. diff --git a/pos_disable_payment/doc/index.rst b/pos_disable_payment/doc/index.rst new file mode 100644 index 0000000000..6db73d2238 --- /dev/null +++ b/pos_disable_payment/doc/index.rst @@ -0,0 +1,8 @@ +========================= + Disable payments in POS +========================= + +Installation +============ + +* `Install `__ this module in a usual way diff --git a/pos_disable_payment/i18n/de.po b/pos_disable_payment/i18n/de.po new file mode 100644 index 0000000000..56c703daf1 --- /dev/null +++ b/pos_disable_payment/i18n/de.po @@ -0,0 +1,87 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_disable_payment +# +# Translators: +# Translation Bot , 2017 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-27 23:55+0000\n" +"PO-Revision-Date: 2017-11-23 10:29+0000\n" +"Last-Translator: Translation Bot , 2017\n" +"Language-Team: German (https://www.transifex.com/it-projects-llc/teams/76080/" +"de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: pos_disable_payment +#: model:ir.ui.view,arch_db:pos_disable_payment.res_users_form_view +msgid "Access" +msgstr "Zugang" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_decrease_kitchen_only +msgid "Allow change Qty for kitchen orders" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_create_order_line +msgid "Allow create order line" +msgstr "Die Erzeugung von Bestellzeilen erlauben" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_decrease_amount +#, fuzzy +msgid "Allow decrease quantity on order line" +msgstr "Die Erzeugung von Bestellzeilen erlauben" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_discount +msgid "Allow discount" +msgstr "Rabatt erlauben" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_edit_price +msgid "Allow edit price" +msgstr "Preisänderungen erlauben" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_manual_customer_selecting +msgid "Allow manual customer selecting" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_payments +msgid "Allow payments" +msgstr "Zahlungen erlauben" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_refund +msgid "Allow refunds" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order +msgid "Allow remove non-empty order" +msgstr "Löschen von nicht-leeren Bestellungen erlauben" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order_line +msgid "Allow remove order line" +msgstr "Das Entfernen von Bestellzeilen erlauben" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_is_restaurant_installed +msgid "Is Restaurant Installed" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model,name:pos_disable_payment.model_res_users +msgid "Users" +msgstr "Benutzer" diff --git a/pos_disable_payment/i18n/es.po b/pos_disable_payment/i18n/es.po new file mode 100644 index 0000000000..bf1224d553 --- /dev/null +++ b/pos_disable_payment/i18n/es.po @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_disable_payment +# +# Translators: +# Translation Bot , 2017 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-27 23:55+0000\n" +"PO-Revision-Date: 2017-11-23 10:29+0000\n" +"Last-Translator: Translation Bot , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/it-projects-llc/teams/76080/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: pos_disable_payment +#: model:ir.ui.view,arch_db:pos_disable_payment.res_users_form_view +msgid "Access" +msgstr "Permisos" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_decrease_kitchen_only +msgid "Allow change Qty for kitchen orders" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_create_order_line +msgid "Allow create order line" +msgstr "Permitir crear líneas de orden" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_decrease_amount +msgid "Allow decrease order line" +msgstr "Permitir eliminar líneas de orden" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_discount +msgid "Allow discount" +msgstr "Pemitir descuentos" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_edit_price +msgid "Allow edit price" +msgstr "Permitir editar precio" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_manual_customer_selecting +msgid "Allow manual customer selecting" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_payments +msgid "Allow payments" +msgstr "Permitir pagar" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_refund +msgid "Allow refunds" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order +msgid "Allow remove non-empty order" +msgstr "Permitir eliminar órdenes no-vacías" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order_line +msgid "Allow remove order line" +msgstr "Permitir eliminar líneas de la orden" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_is_restaurant_installed +msgid "Is Restaurant Installed" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model,name:pos_disable_payment.model_res_users +msgid "Users" +msgstr "Usuarios" diff --git a/pos_disable_payment/i18n/it.po b/pos_disable_payment/i18n/it.po new file mode 100644 index 0000000000..cfd034c0a0 --- /dev/null +++ b/pos_disable_payment/i18n/it.po @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_disable_payment +# +# Translators: +# Sergio Zanchetta , 2018 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-27 23:55+0000\n" +"PO-Revision-Date: 2017-11-23 10:29+0000\n" +"Last-Translator: Sergio Zanchetta , 2018\n" +"Language-Team: Italian (https://www.transifex.com/it-projects-llc/teams/76080/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: pos_disable_payment +#: model:ir.ui.view,arch_db:pos_disable_payment.res_users_form_view +msgid "Access" +msgstr "Permessi" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_decrease_kitchen_only +msgid "Allow change Qty for kitchen orders" +msgstr "Consentire modifica q.tà per ordini cucina" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_create_order_line +msgid "Allow create order line" +msgstr "Consentire creazione righe d'ordine" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_decrease_amount +msgid "Allow decrease order line" +msgstr "Consentire decremento riga d'ordine" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_discount +msgid "Allow discount" +msgstr "Consentire sconti" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_edit_price +msgid "Allow edit price" +msgstr "Consentire modifica prezzo" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_manual_customer_selecting +msgid "Allow manual customer selecting" +msgstr "Consentire selezione manuale del cliente" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_payments +msgid "Allow payments" +msgstr "Consentire pagamenti" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_refund +msgid "Allow refunds" +msgstr "Consentire rimborsi" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order +msgid "Allow remove non-empty order" +msgstr "Consentire rimozione ordini non vuoti" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order_line +msgid "Allow remove order line" +msgstr "Consentire rimozione righe d'ordine" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_is_restaurant_installed +msgid "Is Restaurant Installed" +msgstr "Modulo ristorante installato" + +#. module: pos_disable_payment +#: model:ir.model,name:pos_disable_payment.model_res_users +msgid "Users" +msgstr "Utenti" diff --git a/pos_disable_payment/i18n/pos_disable_payment.pot b/pos_disable_payment/i18n/pos_disable_payment.pot new file mode 100644 index 0000000000..5fcd8cd8cc --- /dev/null +++ b/pos_disable_payment/i18n/pos_disable_payment.pot @@ -0,0 +1,70 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_disable_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \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_disable_payment +#: model:ir.ui.view,arch_db:pos_disable_payment.res_users_form_view +msgid "Access" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_create_order_line +msgid "Allow create order line" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_decrease_amount +msgid "Allow decrease quantity on order line" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_discount +msgid "Allow discount" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_edit_price +msgid "Allow edit price" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_manual_customer_selecting +msgid "Allow manual customer selecting" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_payments +msgid "Allow payments" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_refund +msgid "Allow refunds" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order +msgid "Allow remove non-empty order" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model.fields,field_description:pos_disable_payment.field_res_users_allow_delete_order_line +msgid "Allow remove order line" +msgstr "" + +#. module: pos_disable_payment +#: model:ir.model,name:pos_disable_payment.model_res_users +msgid "Users" +msgstr "" + diff --git a/pos_disable_payment/images/pos_payment_access.png b/pos_disable_payment/images/pos_payment_access.png new file mode 100644 index 0000000000..cb72ca4e39 Binary files /dev/null and b/pos_disable_payment/images/pos_payment_access.png differ diff --git a/pos_disable_payment/models.py b/pos_disable_payment/models.py new file mode 100644 index 0000000000..2d7c9eb1d9 --- /dev/null +++ b/pos_disable_payment/models.py @@ -0,0 +1,25 @@ +from odoo import fields, models + + +class ResUsers(models.Model): + _inherit = "res.users" + + allow_payments = fields.Boolean("Allow payments", default=True) + allow_delete_order = fields.Boolean( + "Allow remove non-empty order", default=True + ) + allow_discount = fields.Boolean("Allow discount", default=True) + allow_edit_price = fields.Boolean("Allow edit price", default=True) + allow_decrease_amount = fields.Boolean( + "Allow decrease quantity on order line", default=True + ) + allow_delete_order_line = fields.Boolean( + "Allow remove order line", default=True + ) + allow_create_order_line = fields.Boolean( + "Allow create order line", default=True + ) + allow_refund = fields.Boolean("Allow refunds", default=True) + allow_manual_customer_selecting = fields.Boolean( + "Allow manual customer selecting", default=True + ) diff --git a/pos_disable_payment/static/description/icon.png b/pos_disable_payment/static/description/icon.png new file mode 100644 index 0000000000..8a058284ed Binary files /dev/null and b/pos_disable_payment/static/description/icon.png differ diff --git a/pos_disable_payment/static/description/index.html b/pos_disable_payment/static/description/index.html new file mode 100644 index 0000000000..83c3defc02 --- /dev/null +++ b/pos_disable_payment/static/description/index.html @@ -0,0 +1,51 @@ +
+
+
+

POS Disable Payment

+

Disable payments in POS

+

+ The module allows to disable payments in POS and in addition set up the following options: +

    +
  • Disable create order line
  • +
  • Disable removing non-empty order
  • +
  • Disable discount button
  • +
  • Disable edit price button
  • +
  • Disable decrease order line
  • +
  • Disable removing order line
  • +
  • Disable refunds
  • +
  • Disable customer selection
  • +
+ This could be useful when using POS only to get price of item by barcode. + Also it could help to solve the problem related to the theft of money by staff members (e.g., the situation is possible when employee can print the bill, take money, then delete all lines and restart a new order on the same order). +

+

+ To use go to Settings → Users section, open user edit form and move to "Point of Sale" tab. +

+
+ +
+
+
+
+ +
+
+

Free Support

+

You will get free support and assistance in case of any issues

+
+
+ +
+
+
+

Need our service?

+

Contact us by email or fill out request form

+ +
+
+
diff --git a/pos_disable_payment/static/description/user_pos_access_new.png b/pos_disable_payment/static/description/user_pos_access_new.png new file mode 100644 index 0000000000..0c99eb55f2 Binary files /dev/null and b/pos_disable_payment/static/description/user_pos_access_new.png differ diff --git a/pos_disable_payment/static/src/css/pos.css b/pos_disable_payment/static/src/css/pos.css new file mode 100644 index 0000000000..7528e97973 --- /dev/null +++ b/pos_disable_payment/static/src/css/pos.css @@ -0,0 +1,4 @@ +.pos .disable { + background: #00000036 !important; + pointer-events: none; +} diff --git a/pos_disable_payment/static/src/js/pos_disable_payment.js b/pos_disable_payment/static/src/js/pos_disable_payment.js new file mode 100644 index 0000000000..3f28a1fd5b --- /dev/null +++ b/pos_disable_payment/static/src/js/pos_disable_payment.js @@ -0,0 +1,305 @@ +odoo.define("pos_disable_payment", function(require) { + "use strict"; + + var chrome = require("point_of_sale.chrome"); + var screens = require("point_of_sale.screens"); + var models = require("point_of_sale.models"); + + models.load_fields("res.users", [ + "allow_payments", + "allow_delete_order", + "allow_discount", + "allow_edit_price", + "allow_decrease_amount", + "allow_delete_order_line", + "allow_create_order_line", + "allow_refund", + "allow_manual_customer_selecting", + ]); + + // Example of event binding and handling (triggering). Look up binding lower bind('change:cashier' ... + // Example extending of class (method set_cashier), than was created using extend. + // /odoo9/addons/point_of_sale/static/src/js/models.js + // exports.PosModel = Backbone.Model.extend ... + var PosModelSuper = models.PosModel; + models.PosModel = models.PosModel.extend({ + set_cashier: function() { + var old_cashier_id = this.db.get_cashier() && this.db.get_cashier().id; + PosModelSuper.prototype.set_cashier.apply(this, arguments); + if (old_cashier_id !== this.db.get_cashier().id) { + this.trigger("change:cashier", this); + } + }, + }); + + chrome.Chrome.include({ + init: function() { + this._super.apply(this, arguments); + this.pos.bind("change:selectedOrder", this.check_allow_delete_order, this); + this.pos.bind("change:cashier", this.check_allow_delete_order, this); + }, + check_allow_delete_order: function() { + var user = this.pos.get_cashier() || this.pos.user; + var order = this.pos.get_order(); + if (order) { + // User option calls "Allow remove non-empty order". So we got to check if its empty we can delete it. + if (!user.allow_delete_order && order.orderlines.length > 0) { + this.$(".deleteorder-button").addClass("disable"); + } else { + this.$(".deleteorder-button").removeClass("disable"); + } + } + }, + loading_hide: function() { + this._super(); + // Extra checks on init + this.check_allow_delete_order(); + }, + }); + chrome.OrderSelectorWidget.include({ + renderElement: function() { + this._super(); + this.chrome.check_allow_delete_order(); + }, + }); + + screens.OrderWidget.include({ + bind_order_events: function() { + this._super(); + var self = this; + var order = this.pos.get("selectedOrder"); + order.orderlines.bind( + "add remove", + this.chrome.check_allow_delete_order, + this.chrome + ); + this.pos.bind("change:cashier", function() { + self.check_numpad_access(); + }); + }, + orderline_change: function(line) { + this._super(line); + var user = this.pos.get_cashier() || this.pos.user; + if (line && line.quantity <= 0) { + if (user.allow_delete_order_line) { + $(".numpad-backspace").removeClass("disable"); + } else { + $(".numpad-backspace").addClass("disable"); + } + } else { + $(".numpad-backspace").removeClass("disable"); + } + this.check_numpad_access(line); + }, + click_line: function(orderline, event) { + this._super(orderline, event); + this.check_numpad_access(orderline); + }, + renderElement: function(scrollbottom) { + this._super(scrollbottom); + this.check_numpad_access(); + }, + check_numpad_access: function(line) { + var order = this.pos.get_order(); + if (order) { + line = line || order.get_selected_orderline(); + var user = this.pos.cashier || this.pos.user; + var state = this.getParent().numpad.state; + if (!line) { + $(".numpad") + .find(".numpad-backspace") + .removeClass("disable"); + $(".numpad") + .find("[data-mode='quantity']") + .removeClass("disable"); + return false; + } + + if (user.allow_decrease_amount) { + // Allow all buttons + if ( + $(".numpad") + .find("[data-mode='quantity']") + .hasClass("disable") + ) { + $(".numpad") + .find("[data-mode='quantity']") + .removeClass("disable"); + state.changeMode("quantity"); + } + if (user.allow_delete_order_line) { + $(".numpad") + .find(".numpad-backspace") + .removeClass("disable"); + } + } else { + // Disable the backspace button of numpad + $(".pads .numpad") + .find(".numpad-backspace") + .addClass("disable"); + } + } + }, + orderline_change_line: function(line) { + this._super(line); + var user = this.pos.cashier || this.pos.user; + var order = this.pos.get_order(); + if (order && !user.allow_decrease_amount) { + // Disable the backspace button of numpad + $(".pads .numpad") + .find(".numpad-backspace") + .addClass("disable"); + } + }, + }); + + // Here regular binding (in init) do not work for some reasons. We got to put binding method in renderElement. + screens.ProductScreenWidget.include({ + start: function() { + this._super(); + this.checkPayAllowed(); + this.checkCreateOrderLine(); + this.checkDiscountButton(); + }, + renderElement: function() { + this._super(); + this.pos.bind("change:cashier", this.checkPayAllowed, this); + this.pos.bind("change:cashier", this.checkCreateOrderLine, this); + this.pos.bind("change:cashier", this.checkDiscountButton, this); + }, + checkCreateOrderLine: function() { + var user = this.pos.get_cashier() || this.pos.user; + if (user.allow_create_order_line) { + $(".numpad").show(); + $(".rightpane").show(); + } else { + $(".numpad").hide(); + $(".rightpane").hide(); + } + }, + checkPayAllowed: function() { + var user = this.pos.get_cashier() || this.pos.user; + if (user.allow_payments) { + this.actionpad.$(".pay").removeClass("disable"); + } else { + this.actionpad.$(".pay").addClass("disable"); + } + }, + checkDiscountButton: function() { + var user = this.pos.get_cashier() || this.pos.user; + if (user.allow_discount) { + $(".control-button.js_discount").removeClass("disable"); + } else { + $(".control-button.js_discount").addClass("disable"); + } + }, + show: function(reset) { + this._super(reset); + if (reset) { + this.order_widget.check_numpad_access(); + } + }, + }); + screens.ScreenWidget.include({ + renderElement: function() { + this._super(); + var user = this.pos.get_cashier() || this.pos.user; + if (user.allow_payments) { + $(".pay").removeClass("disable"); + } else { + $(".pay").addClass("disable"); + } + if (user.allow_create_order_line) { + $(".numpad").show(); + $(".rightpane").show(); + } else { + $(".numpad").hide(); + $(".rightpane").hide(); + } + }, + }); + screens.ActionpadWidget.include({ + init: function(parent, options) { + this._super(parent, options); + this.pos.bind("change:cashier", this.checkManualCustomerSelecting, this); + }, + checkManualCustomerSelecting: function() { + var user = this.pos.get_cashier() || this.pos.user; + if (user.allow_manual_customer_selecting) { + this.$(".set-customer").removeClass("disable"); + } else { + this.$(".set-customer").addClass("disable"); + } + }, + renderElement: function() { + this._super(); + var user = this.pos.get_cashier() || this.pos.user; + if (user.allow_payments) { + $(".pay").removeClass("disable"); + } else { + $(".pay").addClass("disable"); + } + this.checkManualCustomerSelecting(); + }, + }); + screens.PaymentScreenWidget.include({ + init: function(parent, options) { + this._super(parent, options); + this.pos.bind("change:cashier", this.checkManualCustomerSelecting, this); + }, + checkManualCustomerSelecting: function() { + var user = this.pos.get_cashier() || this.pos.user; + if (user.allow_manual_customer_selecting) { + this.$(".js_set_customer").removeClass("disable"); + } else { + this.$(".js_set_customer").addClass("disable"); + } + }, + renderElement: function() { + this._super(); + this.checkManualCustomerSelecting(); + }, + }); + screens.NumpadWidget.include({ + init: function() { + this._super.apply(this, arguments); + this.pos.bind("change:cashier", this.check_access, this); + }, + renderElement: function() { + this._super(); + this.check_access(); + }, + check_access: function() { + var user = this.pos.get_cashier() || this.pos.user; + var order = this.pos.get_order(); + var orderline = false; + if (order) { + orderline = order.get_selected_orderline(); + } + if (user.allow_discount) { + this.$el.find("[data-mode='discount']").removeClass("disable"); + } else { + this.$el.find("[data-mode='discount']").addClass("disable"); + } + if (user.allow_edit_price) { + this.$el.find("[data-mode='price']").removeClass("disable"); + } else { + this.$el.find("[data-mode='price']").addClass("disable"); + } + if (user.allow_refund) { + this.$el.find(".numpad-minus").removeClass("disable"); + } else { + this.$el.find(".numpad-minus").addClass("disable"); + } + if (orderline && orderline.quantity <= 0) { + if (user.allow_delete_order_line) { + this.$el.find(".numpad-backspace").removeClass("disable"); + } else { + this.$el.find(".numpad-backspace").addClass("disable"); + } + } + }, + }); + + return screens; +}); diff --git a/pos_disable_payment/static/src/js/tour.js b/pos_disable_payment/static/src/js/tour.js new file mode 100644 index 0000000000..6b9987528f --- /dev/null +++ b/pos_disable_payment/static/src/js/tour.js @@ -0,0 +1,88 @@ +odoo.define("pos_disable_payment.tour", function(require) { + "use strict"; + + var tour = require("web_tour.tour"); + + tour.register( + "pos_disable_payment_tour", + { + test: true, + url: "/web", + }, + [ + { + trigger: '.o_app[data-menu="4"], .oe_menu_toggler[data-menu="4"]', + content: "Configuration options are available in the Settings app.", + position: "bottom", + }, + { + trigger: ".oe_menu_leaf[data-menu=58]", + content: "Open the Users menu", + position: "right", + }, + { + trigger: ".o_list_view > tbody > tr", + content: "Click on the item", + position: "bottom", + }, + { + trigger: ".o_form_button_edit", + content: "Click to edit user", + position: "bottom", + }, + { + trigger: '.nav-tabs a:contains("Point of Sale")', + content: "Move on Point of Sale tab", + position: "top", + }, + { + trigger: 'label:contains("Allow refunds")', + extra_trigger: + 'div[name="allow_refund"] input:propChecked({disabled: true})', + content: "Uncheck the box Allow refunds", + position: "right", + }, + { + trigger: ".o_form_button_save", + content: "Save the changes", + position: "bottom", + }, + { + trigger: + '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"], .oe_menu_toggler[data-menu-xmlid="point_of_sale.menu_point_root"]', + content: + "Ready to launch your point of sale? Click here.", + position: "bottom", + }, + { + trigger: ".o_pos_kanban button.oe_kanban_action_button", + content: + "

Click to start the point of sale interface. It runs on tablets, laptops, or industrial hardware.

Once the session launched, the system continues to run without an internet connection.

", + position: "bottom", + }, + { + content: "Switch to table or make dummy action", + trigger: + ".table:not(.oe_invisible .neworder-button), .order-button.selected", + position: "bottom", + timeout: 20000, + }, + { + trigger: ".product-list .product", + content: "Add the first product", + position: "top", + }, + { + content: "Hidden", + trigger: ".pads", + run: function() { + if (!$(".numpad-minus").css("visibility") === "hidden") { + console.log("error", "The button is not hidden"); + } else { + console.log("Refunding feature is blocked as configured"); + } + }, + }, + ] + ); +}); diff --git a/pos_disable_payment/tests/__init__.py b/pos_disable_payment/tests/__init__.py new file mode 100644 index 0000000000..7ea835c5f7 --- /dev/null +++ b/pos_disable_payment/tests/__init__.py @@ -0,0 +1 @@ +from . import test_default diff --git a/pos_disable_payment/tests/test_default.py b/pos_disable_payment/tests/test_default.py new file mode 100644 index 0000000000..a86893cdec --- /dev/null +++ b/pos_disable_payment/tests/test_default.py @@ -0,0 +1,16 @@ +import odoo.tests + + +@odoo.tests.common.at_install(False) +@odoo.tests.common.post_install(True) +class TestUi(odoo.tests.HttpCase): + def test_01_pos_is_loaded(self): + self.phantom_js( + "/web", + "odoo.__DEBUG__.services['web_tour.tour']" + ".run('pos_disable_payment_tour')", + "odoo.__DEBUG__.services['web_tour.tour']" + ".tours.pos_disable_payment_tour.ready", + login="admin", + timeout=240, + ) diff --git a/pos_disable_payment/views.xml b/pos_disable_payment/views.xml new file mode 100644 index 0000000000..1c30df0eaf --- /dev/null +++ b/pos_disable_payment/views.xml @@ -0,0 +1,52 @@ + + +