diff --git a/pos_customer_required/README.rst b/pos_customer_required/README.rst new file mode 100644 index 0000000..99565a0 --- /dev/null +++ b/pos_customer_required/README.rst @@ -0,0 +1,126 @@ +============================== +Point of Sale Require Customer +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-OCA%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/14.0/pos_customer_required + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-14-0/pos-14-0-pos_customer_required + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/184/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module was written to extend the functionality of odoo pos +and allows you to require a customer for each pos order. In the +pos session configuration, you can choose to require the customer for pos +orders. + +If a customer is not selected, the pos ui will display an error message. +In the backend the customer field is required when needed. + +Two new options are available: + +* Customer 'Required before starting the order'; +* Customer 'Required before paying'; + +'Required before starting the order' Option +------------------------------------------- +In the frontend PoS, the default screen is the screen to select customers. + +* Users are not allowed to start selling before having selected a customer; +* Users can not 'deselect a customer', only select an other one; + +'Required before paying' Option +------------------------------- +In the frontend PoS, the user can start selling, but if the user tries to +make payment and if a customer is not selected, the pos ui will display an +error message. + + +.. image:: https://raw.githubusercontent.com/pos_customer_required/static/description/frontend_pos_error_message.png + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +* go to point of sale -> configuration -> point of sales +* select the point of sales you want configure +* search for the "Require Customer" and choose between the following values: + * 'Optional'; (this module has no effect on this PoS config) + * 'Required before paying'; + * 'Required before starting the order'; + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/184/9.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Apertoso NV +* La Louve +* NuoBiT + +Contributors +~~~~~~~~~~~~ + +* Jos De Graeve +* Sylvain LE GAL +* Pedro M. Baeza ( reviews & feedback ) +* Druidoo +* Eric Antones +* Kilian Niubo + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_customer_required/__init__.py b/pos_customer_required/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/pos_customer_required/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_customer_required/__manifest__.py b/pos_customer_required/__manifest__.py new file mode 100644 index 0000000..e063ef5 --- /dev/null +++ b/pos_customer_required/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2004 apertoso NV - Jos DE GRAEVE +# Copyright 2016 La Louve - Sylvain LE GAL +# Copyright 2019 Druidoo - (https://www.druidoo.io) +# Copyright 2022 NuoBiT - Eric Antones +# Copyright 2022 NuoBiT - Kilian Niubo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +{ + "name": "Point of Sale Require Customer", + "version": "16.0.1.0.0", + "category": "Point Of Sale", + "summary": "Point of Sale Require Customer", + "author": "Apertoso NV, La Louve, NuoBiT, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "depends": [ + "point_of_sale", + ], + "data": [ + # "views/assets.xml", + "views/pos_config_view.xml", + "views/pos_order_view.xml", + ], + "assets": {"point_of_sale.assets": ["/pos_customer_required/static/src/js/*.js"]}, + "installable": True, +} diff --git a/pos_customer_required/i18n/ca.po b/pos_customer_required/i18n/ca.po new file mode 100644 index 0000000..d53f7fb --- /dev/null +++ b/pos_customer_required/i18n/ca.po @@ -0,0 +1,103 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_customer_required +# +# Translators: +# Marc Tormo i Bochaca , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-28 05:50+0000\n" +"PO-Revision-Date: 2020-02-12 19:13+0000\n" +"Last-Translator: Carles Antoli \n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\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" +"X-Generator: Weblate 3.10\n" + +#. module: pos_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "An anonymous order cannot be confirmed" +msgstr "Una comanda anònima no pot ser confirmada" + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_make_payment.py:0 +#, python-format +msgid "" +"An anonymous order cannot be confirmed.\n" +"Please select a customer for this order." +msgstr "" +"Una comanda anònima no pot ser confirmada.\n" +"Si us plau seleccioneu un client per a aquesta comanda." + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_order.py:0 +#, python-format +msgid "Customer is required for this order and is missing." +msgstr "En necessari que hi hagi un client per a aquesta comanda i no hi és." + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__no +msgid "Optional" +msgstr "Opcional" + +#. module: pos_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "Please select a customer for this order." +msgstr "Si us plau seleccioneu un client per a aquesta comanda." + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_config +#, fuzzy +msgid "Point of Sale Configuration" +msgstr "Pagament del Punt de Venda " + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_order +#, fuzzy +msgid "Point of Sale Orders" +msgstr "Punt de Venda " + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_make_payment +msgid "Point of Sale Payment" +msgstr "Pagament del Punt de Venda" + +#. module: pos_customer_required +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_order__require_customer +#: model_terms:ir.ui.view,arch_db:pos_customer_required.view_pos_config_form +msgid "Require Customer" +msgstr "Client requerit" + +#. module: pos_customer_required +#: model:ir.model.fields,help:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,help:pos_customer_required.field_pos_order__require_customer +msgid "" +"Require customer for orders in this point of sale:\n" +"* 'Optional' (customer is optional);\n" +"* 'Required before paying';\n" +"* 'Required before starting the order';" +msgstr "" +"Requerir client per a comandes en aquest punt de venda:\n" +"* 'Opcional' (el client és opcional);\n" +"* 'Requerit abans de pagar';\n" +"* 'Requerit abans d'entrar la comanda';" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__payment +msgid "Required before paying" +msgstr "Requerit abans de pagar" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__order +msgid "Required before starting the order" +msgstr "Requerit abans d'entrar la comanda" diff --git a/pos_customer_required/i18n/es.po b/pos_customer_required/i18n/es.po new file mode 100644 index 0000000..1506521 --- /dev/null +++ b/pos_customer_required/i18n/es.po @@ -0,0 +1,92 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_customer_required +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-02-12 19:13+0000\n" +"Last-Translator: Carles Antoli \n" +"Language-Team: none\n" +"Language: es\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" +"X-Generator: Weblate 3.10\n" + +#. module: pos_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "An anonymous order cannot be confirmed" +msgstr "Un pedido anónimo no puede ser confirmado" + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_make_payment.py:0 +#, python-format +msgid "An anonymous order cannot be confirmed.\n" +"Please select a customer for this order." +msgstr "" +"Un pedido anónimo no puede ser confirmado.\n" +"Por favor seleccione un cliente para este pedido." + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_order.py:0 +#, python-format +msgid "Customer is required for this order and is missing." +msgstr "" +"En necesario que haya un cliente para este pedido y no está seleccionado." + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__no +msgid "Optional" +msgstr "Opcional" + +#. module: pos_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "Please select a customer for this order." +msgstr "Por favor seleccione un cliente para este pedido." + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del punto de venta" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_order +msgid "Point of Sale Orders" +msgstr "Pedidos del punto de venta" + +#. module: pos_customer_required +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_order__require_customer +#: model_terms:ir.ui.view,arch_db:pos_customer_required.view_pos_config_form +msgid "Require Customer" +msgstr "Cliente requerido" + +#. module: pos_customer_required +#: model:ir.model.fields,help:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,help:pos_customer_required.field_pos_order__require_customer +msgid "Require customer for orders in this point of sale:\n" +"* 'Optional' (customer is optional);\n" +"* 'Required before paying';\n" +"* 'Required before starting the order';" +msgstr "" +"Requerir cliente para pedidos en este punto de venta:\n" +"* 'Opcional' (el cliente es opcional);\n" +"* 'Requerido antes de pagar';\n" +"* 'Requerido antes de comenzar el pedido';" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__payment +msgid "Required before paying" +msgstr "Requerido antes de pagar" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__order +msgid "Required before starting the order" +msgstr "Requerido antes de comenzar el pedido" diff --git a/pos_customer_required/i18n/fr.po b/pos_customer_required/i18n/fr.po new file mode 100644 index 0000000..180411f --- /dev/null +++ b/pos_customer_required/i18n/fr.po @@ -0,0 +1,103 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_customer_required +# +# Translators: +# OCA Transbot , 2016 +# leemannd , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-21 03:45+0000\n" +"PO-Revision-Date: 2016-12-21 03:45+0000\n" +"Last-Translator: leemannd , 2016\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\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_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "An anonymous order cannot be confirmed" +msgstr "Une commande anonyme ne peut pas être confirmée" + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_make_payment.py:0 +#, python-format +msgid "" +"An anonymous order cannot be confirmed.\n" +"Please select a customer for this order." +msgstr "" +"Une commande anonyme ne peut pas être confirmée\n" +"Sélectionnez un client pour cette commande." + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_order.py:0 +#, python-format +msgid "Customer is required for this order and is missing." +msgstr "Un client est requis et manquant." + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__no +msgid "Optional" +msgstr "Facultatif" + +#. module: pos_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "Please select a customer for this order." +msgstr "Sélectionnez un client pour cette commande." + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_config +#, fuzzy +msgid "Point of Sale Configuration" +msgstr "Paiement du ticket" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_order +#, fuzzy +msgid "Point of Sale Orders" +msgstr "Point de vente" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_make_payment +msgid "Point of Sale Payment" +msgstr "Paiement du ticket" + +#. module: pos_customer_required +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_order__require_customer +#: model_terms:ir.ui.view,arch_db:pos_customer_required.view_pos_config_form +msgid "Require Customer" +msgstr "Client requis" + +#. module: pos_customer_required +#: model:ir.model.fields,help:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,help:pos_customer_required.field_pos_order__require_customer +msgid "" +"Require customer for orders in this point of sale:\n" +"* 'Optional' (customer is optional);\n" +"* 'Required before paying';\n" +"* 'Required before starting the order';" +msgstr "" +"Client requis pour les commandes de ce terminal de point de vente:\n" +"* 'Optionnel' (Le client est optionnel);\n" +"* 'Le client est requis avant le payement';\n" +"* 'Le client est requis avant de commencer la commande';" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__payment +msgid "Required before paying" +msgstr "Requis avant de payer" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__order +msgid "Required before starting the order" +msgstr "Requis avant de commencer la vente" diff --git a/pos_customer_required/i18n/nl_NL.po b/pos_customer_required/i18n/nl_NL.po new file mode 100644 index 0000000..17a84d9 --- /dev/null +++ b/pos_customer_required/i18n/nl_NL.po @@ -0,0 +1,100 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_customer_required +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-13 19:57+0000\n" +"PO-Revision-Date: 2016-12-13 19:57+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\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_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "An anonymous order cannot be confirmed" +msgstr "Een anoniem kassa order kan niet worden bevestigd" + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_make_payment.py:0 +#, python-format +msgid "" +"An anonymous order cannot be confirmed.\n" +"Please select a customer for this order." +msgstr "" + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_order.py:0 +#, python-format +msgid "Customer is required for this order and is missing." +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__no +msgid "Optional" +msgstr "" + +#. module: pos_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "Please select a customer for this order." +msgstr "" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_config +#, fuzzy +msgid "Point of Sale Configuration" +msgstr "Kassa" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_order +#, fuzzy +msgid "Point of Sale Orders" +msgstr "Kassa" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_make_payment +msgid "Point of Sale Payment" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_order__require_customer +#: model_terms:ir.ui.view,arch_db:pos_customer_required.view_pos_config_form +msgid "Require Customer" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields,help:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,help:pos_customer_required.field_pos_order__require_customer +msgid "" +"Require customer for orders in this point of sale:\n" +"* 'Optional' (customer is optional);\n" +"* 'Required before paying';\n" +"* 'Required before starting the order';" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__payment +msgid "Required before paying" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__order +msgid "Required before starting the order" +msgstr "" + +#~ msgid "Require customer" +#~ msgstr "Klant verplichten" diff --git a/pos_customer_required/i18n/pos_customer_required.pot b/pos_customer_required/i18n/pos_customer_required.pot new file mode 100644 index 0000000..fca0c37 --- /dev/null +++ b/pos_customer_required/i18n/pos_customer_required.pot @@ -0,0 +1,88 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_customer_required +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "An anonymous order cannot be confirmed" +msgstr "" + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_make_payment.py:0 +#, python-format +msgid "An anonymous order cannot be confirmed.\n" +"Please select a customer for this order." +msgstr "" + +#. module: pos_customer_required +#: code:addons/pos_customer_required/models/pos_order.py:0 +#, python-format +msgid "Customer is required for this order and is missing." +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__no +msgid "Optional" +msgstr "" + +#. module: pos_customer_required +#. openerp-web +#: code:addons/pos_customer_required/static/src/js/PaymentScreen.js:0 +#, python-format +msgid "Please select a customer for this order." +msgstr "" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model,name:pos_customer_required.model_pos_make_payment +msgid "Point of Sale Payment" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,field_description:pos_customer_required.field_pos_order__require_customer +#: model_terms:ir.ui.view,arch_db:pos_customer_required.view_pos_config_form +msgid "Require Customer" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields,help:pos_customer_required.field_pos_config__require_customer +#: model:ir.model.fields,help:pos_customer_required.field_pos_order__require_customer +msgid "Require customer for orders in this point of sale:\n" +"* 'Optional' (customer is optional);\n" +"* 'Required before paying';\n" +"* 'Required before starting the order';" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__payment +msgid "Required before paying" +msgstr "" + +#. module: pos_customer_required +#: model:ir.model.fields.selection,name:pos_customer_required.selection__pos_config__require_customer__order +msgid "Required before starting the order" +msgstr "" + diff --git a/pos_customer_required/models/__init__.py b/pos_customer_required/models/__init__.py new file mode 100644 index 0000000..51311ba --- /dev/null +++ b/pos_customer_required/models/__init__.py @@ -0,0 +1,4 @@ +from . import pos_config +from . import pos_order +from . import pos_make_payment +from . import res_config_setting diff --git a/pos_customer_required/models/pos_config.py b/pos_customer_required/models/pos_config.py new file mode 100644 index 0000000..5f917e5 --- /dev/null +++ b/pos_customer_required/models/pos_config.py @@ -0,0 +1,24 @@ +# Copyright 2004 apertoso NV - Jos DE GRAEVE +# Copyright 2016 La Louve - Sylvain LE GAL +# Copyright 2019 Druidoo - (https://www.druidoo.io) +# 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" + + require_customer = fields.Selection( + [ + ("no", "Optional"), + ("payment", "Required before paying"), + ("order", "Required before starting the order"), + ], + string="Require Customer", + default="no", + help="Require customer for orders in this point of sale:\n" + "* 'Optional' (customer is optional);\n" + "* 'Required before paying';\n" + "* 'Required before starting the order';", + ) diff --git a/pos_customer_required/models/pos_make_payment.py b/pos_customer_required/models/pos_make_payment.py new file mode 100644 index 0000000..6fb24d6 --- /dev/null +++ b/pos_customer_required/models/pos_make_payment.py @@ -0,0 +1,29 @@ +# Copyright 2016 La Louve - Sylvain LE GAL +# Copyright 2019 Druidoo - (https://www.druidoo.io) +# Copyright 2022 NuoBiT - Eric Antones +# Copyright 2022 NuoBiT - Kilian Niubo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + + +from odoo import _, models +from odoo.exceptions import UserError + + +class PosMakePayment(models.TransientModel): + _inherit = "pos.make.payment" + + def check(self): + # Load current order + order_obj = self.env["pos.order"] + order = order_obj.browse(self.env.context.get("active_id", False)) + + # Check if control is required + if not order.partner_id and order.session_id.config_id.require_customer != "no": + raise UserError( + _( + "An anonymous order cannot be confirmed.\n" + "Please select a customer for this order." + ) + ) + + return super(PosMakePayment, self).check() diff --git a/pos_customer_required/models/pos_order.py b/pos_customer_required/models/pos_order.py new file mode 100644 index 0000000..52bcaa7 --- /dev/null +++ b/pos_customer_required/models/pos_order.py @@ -0,0 +1,22 @@ +# Copyright 2004 apertoso NV - Jos DE GRAEVE +# Copyright 2016 La Louve - Sylvain LE GAL +# Copyright 2019 Druidoo - (https://www.druidoo.io) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo import _, api, exceptions, fields, models + + +class PosOrder(models.Model): + _inherit = "pos.order" + + require_customer = fields.Selection( + related="session_id.config_id.require_customer", + ) + + @api.constrains("partner_id", "session_id") + def _check_partner(self): + for rec in self: + if rec.require_customer != "no" and not rec.partner_id: + raise exceptions.ValidationError( + _("Customer is required for this order and is missing.") + ) diff --git a/pos_customer_required/models/res_config_setting.py b/pos_customer_required/models/res_config_setting.py new file mode 100644 index 0000000..eb065b4 --- /dev/null +++ b/pos_customer_required/models/res_config_setting.py @@ -0,0 +1,11 @@ +from odoo import api, fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + require_customer = fields.Selection( + related="pos_config_id.require_customer", + readonly=False, + help="Require customer in Point of Sale", + ) diff --git a/pos_customer_required/readme/CONFIGURE.rst b/pos_customer_required/readme/CONFIGURE.rst new file mode 100644 index 0000000..3754a78 --- /dev/null +++ b/pos_customer_required/readme/CONFIGURE.rst @@ -0,0 +1,8 @@ +To configure this module, you need to: + +* go to point of sale -> configuration -> point of sales +* select the point of sales you want configure +* search for the "Require Customer" and choose between the following values: + * 'Optional'; (this module has no effect on this PoS config) + * 'Required before paying'; + * 'Required before starting the order'; diff --git a/pos_customer_required/readme/CONTRIBUTORS.rst b/pos_customer_required/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..535d9bc --- /dev/null +++ b/pos_customer_required/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Jos De Graeve +* Sylvain LE GAL +* Pedro M. Baeza ( reviews & feedback ) +* Druidoo +* Eric Antones +* Kilian Niubo diff --git a/pos_customer_required/readme/DESCRIPTION.rst b/pos_customer_required/readme/DESCRIPTION.rst new file mode 100644 index 0000000..4f28974 --- /dev/null +++ b/pos_customer_required/readme/DESCRIPTION.rst @@ -0,0 +1,28 @@ +This module was written to extend the functionality of odoo pos +and allows you to require a customer for each pos order. In the +pos session configuration, you can choose to require the customer for pos +orders. + +If a customer is not selected, the pos ui will display an error message. +In the backend the customer field is required when needed. + +Two new options are available: + +* Customer 'Required before starting the order'; +* Customer 'Required before paying'; + +'Required before starting the order' Option +------------------------------------------- +In the frontend PoS, the default screen is the screen to select customers. + +* Users are not allowed to start selling before having selected a customer; +* Users can not 'deselect a customer', only select an other one; + +'Required before paying' Option +------------------------------- +In the frontend PoS, the user can start selling, but if the user tries to +make payment and if a customer is not selected, the pos ui will display an +error message. + + +.. image:: /pos_customer_required/static/description/frontend_pos_error_message.png diff --git a/pos_customer_required/readme/USAGE.rst b/pos_customer_required/readme/USAGE.rst new file mode 100644 index 0000000..8471f7f --- /dev/null +++ b/pos_customer_required/readme/USAGE.rst @@ -0,0 +1,3 @@ +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/184/9.0 diff --git a/pos_customer_required/static/description/frontend_pos_error_message.png b/pos_customer_required/static/description/frontend_pos_error_message.png new file mode 100644 index 0000000..823bb99 Binary files /dev/null and b/pos_customer_required/static/description/frontend_pos_error_message.png differ diff --git a/pos_customer_required/static/description/icon.png b/pos_customer_required/static/description/icon.png new file mode 100644 index 0000000..637d357 Binary files /dev/null and b/pos_customer_required/static/description/icon.png differ diff --git a/pos_customer_required/static/description/index.html b/pos_customer_required/static/description/index.html new file mode 100644 index 0000000..aa3257a --- /dev/null +++ b/pos_customer_required/static/description/index.html @@ -0,0 +1,475 @@ + + + + + + +Point of Sale Require Customer + + + +
+

Point of Sale Require Customer

+ + +

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runbot

+

This module was written to extend the functionality of odoo pos +and allows you to require a customer for each pos order. In the +pos session configuration, you can choose to require the customer for pos +orders.

+

If a customer is not selected, the pos ui will display an error message. +In the backend the customer field is required when needed.

+

Two new options are available:

+
    +
  • Customer ‘Required before starting the order’;
  • +
  • Customer ‘Required before paying’;
  • +
+
+

‘Required before starting the order’ Option

+

In the frontend PoS, the default screen is the screen to select customers.

+
    +
  • Users are not allowed to start selling before having selected a customer;
  • +
  • Users can not ‘deselect a customer’, only select an other one;
  • +
+
+
+

‘Required before paying’ Option

+

In the frontend PoS, the user can start selling, but if the user tries to +make payment and if a customer is not selected, the pos ui will display an +error message.

+https://raw.githubusercontent.com/pos_customer_required/static/description/frontend_pos_error_message.png +

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  • go to point of sale -> configuration -> point of sales
  • +
  • select the point of sales you want configure
  • +
  • +
    search for the “Require Customer” and choose between the following values:
    +
      +
    • ‘Optional’; (this module has no effect on this PoS config)
    • +
    • ‘Required before paying’;
    • +
    • ‘Required before starting the order’;
    • +
    +
    +
    +
  • +
+
+
+

Usage

+Try me on Runbot +
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Apertoso NV
  • +
  • La Louve
  • +
  • NuoBiT
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/pos project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/pos_customer_required/static/src/js/PaymentScreen.js b/pos_customer_required/static/src/js/PaymentScreen.js new file mode 100644 index 0000000..b0ebb12 --- /dev/null +++ b/pos_customer_required/static/src/js/PaymentScreen.js @@ -0,0 +1,37 @@ +/* Copyright apertoso NV- Jos DE GRAEVE + Copyright La Louve - Sylvain LE GAL + Copyright NuoBiT - Eric Antones + Copyright NuoBiT - Kilian Niubo + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) */ +odoo.define("pos_customer_required.PaymentScreen", function (require) { + "use strict"; + + const PaymentScreen = require("point_of_sale.PaymentScreen"); + const Registries = require("point_of_sale.Registries"); + const core = require("web.core"); + const _t = core._t; + + const PosRequiredCustomerPaymentScreen = (PaymentScreen) => + class extends PaymentScreen { + async _isOrderValid(isForceValidate) { + if ( + this.env.pos.config.require_customer === "payment" && + !this.env.pos.get_order().get_partner() + ) { + const result = await this.showPopup("ConfirmPopup", { + title: _t("An anonymous order cannot be confirmed"), + body: _t("Please select a customer for this order."), + }); + if (result.confirmed) { + this.selectClient(); + } + return false; + } + return super._isOrderValid(isForceValidate); + } + }; + + Registries.Component.extend(PaymentScreen, PosRequiredCustomerPaymentScreen); + + return PosRequiredCustomerPaymentScreen; +}); diff --git a/pos_customer_required/static/src/js/ProductScreen.js b/pos_customer_required/static/src/js/ProductScreen.js new file mode 100644 index 0000000..899e844 --- /dev/null +++ b/pos_customer_required/static/src/js/ProductScreen.js @@ -0,0 +1,38 @@ +/** @odoo-module **/ + +import {Component} from "point_of_sale.Registries"; +import ProductScreen from "point_of_sale.ProductScreen"; +const { onMounted } = owl; + +const PosRequiredCustomerProductScreen = (ProductScreen) => + class extends ProductScreen { + + setup() { + super.setup(); + onMounted(async () => { + if ( + this.env.pos.config.require_customer === "order" && + !this.env.pos.get_order().get_partner() + ) { + this.onClickPartner(); + } + }); + } + + async _onClickPay() { + if ( + (this.env.pos.config.require_customer === "order" || + this.env.pos.config.require_customer === "payment") && + !this.env.pos.get_order().get_partner() + ) { + this.onClickPartner(); + } + else { + return super._onClickPay(...arguments); + } + } + + }; + +Component.extend(ProductScreen, PosRequiredCustomerProductScreen); +export default ProductScreen; \ No newline at end of file diff --git a/pos_customer_required/tests/__init__.py b/pos_customer_required/tests/__init__.py new file mode 100644 index 0000000..23b45ed --- /dev/null +++ b/pos_customer_required/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pos_customer_required diff --git a/pos_customer_required/tests/test_pos_customer_required.py b/pos_customer_required/tests/test_pos_customer_required.py new file mode 100644 index 0000000..189e198 --- /dev/null +++ b/pos_customer_required/tests/test_pos_customer_required.py @@ -0,0 +1,49 @@ +import odoo.tests.common as common +from odoo import exceptions + + +class TestPosCustomerRequired(common.TransactionCase): + def setUp(self): + super().setUp() + self.pos_config = self.env.ref("point_of_sale.pos_config_main").copy() + + def test_customer_not_required(self): + self.pos_config.require_customer = "no" + + # Now Create new session and create a + # pos order in this session + pos_session = self.env["pos.session"].create( + {"user_id": 1, "config_id": self.pos_config.id} + ) + # should not raise any exception + self.env["pos.order"].create( + { + "session_id": pos_session.id, + "partner_id": False, + "amount_tax": 0.0, + "amount_total": 0.0, + "amount_paid": 0.0, + "amount_return": 0.0, + } + ) + + def test_customer_is_required(self): + self.pos_config.require_customer = "order" + + # Now Create new session and create a + # pos order in this session + pos_session = self.env["pos.session"].create( + {"user_id": 1, "config_id": self.pos_config.id} + ) + # should raise exceptions.ValidationError + with self.assertRaises(exceptions.ValidationError): + self.env["pos.order"].create( + { + "session_id": pos_session.id, + "partner_id": False, + "amount_tax": 0.0, + "amount_total": 0.0, + "amount_paid": 0.0, + "amount_return": 0.0, + } + ) diff --git a/pos_customer_required/views/assets.xml b/pos_customer_required/views/assets.xml new file mode 100644 index 0000000..415fbcf --- /dev/null +++ b/pos_customer_required/views/assets.xml @@ -0,0 +1,16 @@ + + + +