diff --git a/pos_require_product_quantity/README.rst b/pos_require_product_quantity/README.rst new file mode 100644 index 0000000..fa56a67 --- /dev/null +++ b/pos_require_product_quantity/README.rst @@ -0,0 +1,79 @@ +=============================== +Require Product Quantity in POS +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_require_product_quantity + :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_require_product_quantity + :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 forbids adding empty order lines on POS orders. + +When clicking on the "Payment" button in the Point of Sale, +a popup is shown if product quantity for one or more order +lines is set to 0. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Coop IT Easy SCRLfs + +Contributors +~~~~~~~~~~~~ + +* Robin Keunen +* Iván Todorovich +* Foram Shah + +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_require_product_quantity/__init__.py b/pos_require_product_quantity/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/pos_require_product_quantity/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_require_product_quantity/__manifest__.py b/pos_require_product_quantity/__manifest__.py new file mode 100644 index 0000000..e59b799 --- /dev/null +++ b/pos_require_product_quantity/__manifest__.py @@ -0,0 +1,28 @@ +# Copyright 2019-2020 Coop IT Easy SCRLfs +# @author Robin Keunen +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Require Product Quantity in POS", + "version": "16.0.1.0.0", + "author": "Coop IT Easy SCRLfs, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "license": "AGPL-3", + "category": "Point of Sale", + "summary": """ + A popup is shown if product quantity is set to 0 for one or more order + lines when clicking on "Payment" button. + """, + "depends": [ + "point_of_sale", + ], + "data": [ + "views/pos_config.xml", + "views/assets.xml", + ], + "assets": { + "point_of_sale.assets": [ + "pos_require_product_quantity/static/src/js/screens.js" + ], + }, + "installable": True, +} diff --git a/pos_require_product_quantity/i18n/es.po b/pos_require_product_quantity/i18n/es.po new file mode 100644 index 0000000..a1a694f --- /dev/null +++ b/pos_require_product_quantity/i18n/es.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_require_product_quantity +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-07-27 11:19+0000\n" +"Last-Translator: Daniel Martinez Vila \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_require_product_quantity +#. openerp-web +#: code:addons/pos_require_product_quantity/static/src/js/screens.js:30 +#, python-format +msgid "Missing quantities" +msgstr "Cantidades faltantes" + +#. module: pos_require_product_quantity +#. openerp-web +#: code:addons/pos_require_product_quantity/static/src/js/screens.js:32 +#, python-format +msgid "No quantity set for products:" +msgstr "No hay cantidad establecida para productos:" + +#. module: pos_require_product_quantity +#: model:ir.model,name:pos_require_product_quantity.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuración del punto de venta" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config__require_product_quantity +msgid "Require product quantity in POS" +msgstr "Requerir cantidad de producto en PdV" + +#. module: pos_require_product_quantity +#: model_terms:ir.ui.view,arch_db:pos_require_product_quantity.view_pos_config_form +msgid "" +"Show pop-up when product quantity is set to 0 for one or more order lines " +"when clicking on \"Payment\" button." +msgstr "" +"Mostrar ventana emergente cuando la cantidad del producto se establece en 0 " +"para una o más líneas de pedido al hacer clic en el botón \"Pago\"." diff --git a/pos_require_product_quantity/i18n/pos_require_product_quantity.pot b/pos_require_product_quantity/i18n/pos_require_product_quantity.pot new file mode 100644 index 0000000..64a983f --- /dev/null +++ b/pos_require_product_quantity/i18n/pos_require_product_quantity.pot @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_require_product_quantity +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config__display_name +msgid "Display Name" +msgstr "" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config__id +msgid "ID" +msgstr "" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config____last_update +msgid "Last Modified on" +msgstr "" + +#. module: pos_require_product_quantity +#. openerp-web +#: code:addons/pos_require_product_quantity/static/src/js/screens.js:0 +#, python-format +msgid "Missing quantities" +msgstr "" + +#. module: pos_require_product_quantity +#. openerp-web +#: code:addons/pos_require_product_quantity/static/src/js/screens.js:0 +#, python-format +msgid "No quantity set for products:" +msgstr "" + +#. module: pos_require_product_quantity +#: model:ir.model,name:pos_require_product_quantity.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config__require_product_quantity +msgid "Require product quantity in POS" +msgstr "" + +#. module: pos_require_product_quantity +#: model_terms:ir.ui.view,arch_db:pos_require_product_quantity.pos_config_view_form +msgid "" +"Show pop-up when product quantity is set to 0 for one or more order lines " +"when clicking on \"Payment\" button." +msgstr "" diff --git a/pos_require_product_quantity/i18n/pt.po b/pos_require_product_quantity/i18n/pt.po new file mode 100644 index 0000000..1a80372 --- /dev/null +++ b/pos_require_product_quantity/i18n/pt.po @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_require_product_quantity +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-02-01 12:33+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\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 4.3.2\n" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config__display_name +msgid "Display Name" +msgstr "Nome a Exibir" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config__id +msgid "ID" +msgstr "ID" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config____last_update +msgid "Last Modified on" +msgstr "Última Modificação em" + +#. module: pos_require_product_quantity +#. openerp-web +#: code:addons/pos_require_product_quantity/static/src/js/screens.js:0 +#, python-format +msgid "Missing quantities" +msgstr "Quantidades em falta" + +#. module: pos_require_product_quantity +#. openerp-web +#: code:addons/pos_require_product_quantity/static/src/js/screens.js:0 +#, python-format +msgid "No quantity set for products:" +msgstr "Não foi definida quantidade para os produtos:" + +#. module: pos_require_product_quantity +#: model:ir.model,name:pos_require_product_quantity.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuração do Ponto de Venda" + +#. module: pos_require_product_quantity +#: model:ir.model.fields,field_description:pos_require_product_quantity.field_pos_config__require_product_quantity +msgid "Require product quantity in POS" +msgstr "Requerer quantidade no POS" + +#. module: pos_require_product_quantity +#: model_terms:ir.ui.view,arch_db:pos_require_product_quantity.pos_config_view_form +msgid "" +"Show pop-up when product quantity is set to 0 for one or more order lines " +"when clicking on \"Payment\" button." +msgstr "" +"Exibir pop-up quando a quantidade do produto for 0 em pelo menos uma linha " +"ao clicar no botão \"Pagamento\"." diff --git a/pos_require_product_quantity/models/__init__.py b/pos_require_product_quantity/models/__init__.py new file mode 100644 index 0000000..53fc156 --- /dev/null +++ b/pos_require_product_quantity/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_config +from . import res_config_setting diff --git a/pos_require_product_quantity/models/pos_config.py b/pos_require_product_quantity/models/pos_config.py new file mode 100644 index 0000000..0e5c4cc --- /dev/null +++ b/pos_require_product_quantity/models/pos_config.py @@ -0,0 +1,14 @@ +# Copyright 2019-2020 Coop IT Easy SCRLfs +# @author Robin Keunen +# 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_product_quantity = fields.Boolean( + string="Require product quantity in POS", + default=False, + ) diff --git a/pos_require_product_quantity/models/res_config_setting.py b/pos_require_product_quantity/models/res_config_setting.py new file mode 100644 index 0000000..83d4e2e --- /dev/null +++ b/pos_require_product_quantity/models/res_config_setting.py @@ -0,0 +1,11 @@ +from odoo import api, fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + require_product_quantity = fields.Boolean( + related="pos_config_id.require_product_quantity", + readonly=False, + help="Require product quantity in POS", + ) diff --git a/pos_require_product_quantity/readme/CONTRIBUTORS.rst b/pos_require_product_quantity/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..b0ec353 --- /dev/null +++ b/pos_require_product_quantity/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Robin Keunen +* Iván Todorovich +* Foram Shah diff --git a/pos_require_product_quantity/readme/DESCRIPTION.rst b/pos_require_product_quantity/readme/DESCRIPTION.rst new file mode 100644 index 0000000..cc4c84a --- /dev/null +++ b/pos_require_product_quantity/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module forbids adding empty order lines on POS orders. + +When clicking on the "Payment" button in the Point of Sale, +a popup is shown if product quantity for one or more order +lines is set to 0. diff --git a/pos_require_product_quantity/static/description/icon.png b/pos_require_product_quantity/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/pos_require_product_quantity/static/description/icon.png differ diff --git a/pos_require_product_quantity/static/description/index.html b/pos_require_product_quantity/static/description/index.html new file mode 100644 index 0000000..cc781a1 --- /dev/null +++ b/pos_require_product_quantity/static/description/index.html @@ -0,0 +1,424 @@ + + + + + + +Require Product Quantity in POS + + + +
+

Require Product Quantity in POS

+ + +

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

+

This module forbids adding empty order lines on POS orders.

+

When clicking on the “Payment” button in the Point of Sale, +a popup is shown if product quantity for one or more order +lines is set to 0.

+

Table of contents

+ +
+

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

+
    +
  • Coop IT Easy SCRLfs
  • +
+
+
+

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_require_product_quantity/static/src/js/screens.js b/pos_require_product_quantity/static/src/js/screens.js new file mode 100644 index 0000000..a38b898 --- /dev/null +++ b/pos_require_product_quantity/static/src/js/screens.js @@ -0,0 +1,44 @@ +/* + Copyright 2019 Coop IT Easy SCRLfs + Robin Keunen + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +*/ + +odoo.define("pos_require_product_quantity.screens", function (require) { + "use strict"; + + const ProductScreen = require("point_of_sale.ProductScreen"); + const Registries = require("point_of_sale.Registries"); + const {Gui} = require("point_of_sale.Gui"); + var core = require("web.core"); + var _t = core._t; + + const CustomProductScreen = (ProductScreen) => + class extends ProductScreen { + _onClickPay() { + const result = super._onClickPay(...arguments); + var lines_without_qty = _.filter( + this.env.pos.get_order().get_orderlines(), + function (line) { + return line.quantity === 0; + } + ); + if (lines_without_qty.length > 0) { + this.showScreen("ProductScreen"); + Gui.showPopup("ConfirmPopup", { + title: _t("Missing quantities"), + body: + _t("No quantity set for products:") + + "\n" + + _.map(lines_without_qty, function (line) { + return " - " + line.product.display_name; + }).join("\n"), + }); + } + return result; + } + }; + + Registries.Component.extend(ProductScreen, CustomProductScreen); + return ProductScreen; +}); diff --git a/pos_require_product_quantity/views/assets.xml b/pos_require_product_quantity/views/assets.xml new file mode 100644 index 0000000..f802971 --- /dev/null +++ b/pos_require_product_quantity/views/assets.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/pos_require_product_quantity/views/pos_config.xml b/pos_require_product_quantity/views/pos_config.xml new file mode 100644 index 0000000..51ad34a --- /dev/null +++ b/pos_require_product_quantity/views/pos_config.xml @@ -0,0 +1,25 @@ + + + + + pos.config.form.view.inherit + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+ +