diff --git a/pos_require_product_quantity/README.rst b/pos_require_product_quantity/README.rst new file mode 100644 index 00000000..3ce1e370 --- /dev/null +++ b/pos_require_product_quantity/README.rst @@ -0,0 +1,77 @@ +=============================== +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/12.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-12-0/pos-12-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/12.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 + +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 00000000..0650744f --- /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 00000000..fc783371 --- /dev/null +++ b/pos_require_product_quantity/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2019-2020 Coop IT Easy SCRLfs +# Robin Keunen +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Require Product Quantity in POS", + "version": "12.0.0.1.0", + "author": "Coop IT Easy SCRLfs, Odoo Community Association (OCA)", + "website": "https://www.coopiteasy.be", + "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', + ], + 'installable': True, +} diff --git a/pos_require_product_quantity/models/__init__.py b/pos_require_product_quantity/models/__init__.py new file mode 100644 index 00000000..db8634ad --- /dev/null +++ b/pos_require_product_quantity/models/__init__.py @@ -0,0 +1 @@ +from . import pos_config 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 00000000..c64987c0 --- /dev/null +++ b/pos_require_product_quantity/models/pos_config.py @@ -0,0 +1,10 @@ +from odoo import models, fields + + +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/readme/CONTRIBUTORS.rst b/pos_require_product_quantity/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..0bb403b6 --- /dev/null +++ b/pos_require_product_quantity/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Robin Keunen diff --git a/pos_require_product_quantity/readme/DESCRIPTION.rst b/pos_require_product_quantity/readme/DESCRIPTION.rst new file mode 100644 index 00000000..cc4c84a6 --- /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/index.html b/pos_require_product_quantity/static/description/index.html new file mode 100644 index 00000000..a7ece93b --- /dev/null +++ b/pos_require_product_quantity/static/description/index.html @@ -0,0 +1,422 @@ + + + + + + +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
  • +
+
+ +
+

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/pos.js b/pos_require_product_quantity/static/src/js/pos.js new file mode 100644 index 00000000..5fa266d4 --- /dev/null +++ b/pos_require_product_quantity/static/src/js/pos.js @@ -0,0 +1,59 @@ +/* + 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.pos_require_product_quantity', + function (require) { + "use strict"; + + var core = require('web.core'); + var screens = require("point_of_sale.screens"); + + var _t = core._t; + + screens.ActionpadWidget = screens.ActionpadWidget.include({ + renderElement: function () { + var self = this; + this._super(); + + this.$('.pay').click(function () { + + if (self.pos.config.require_product_quantity) { + + var orderlines = self.pos.get_order().orderlines; + var qty_unset_list = []; + + for (var i = 0; i < orderlines.length; i++) { + var line = orderlines.models[i]; + if (line.quantity === 0) { + qty_unset_list.push(line); + } + } + if (qty_unset_list.length > 0) { + self.gui.back(); + var body = _t('No quantity set for products:'); + for (var j = 0; j < qty_unset_list.length; j++) { + body = ( + body + + ' - ' + + qty_unset_list[j].product.display_name + ); + } + self.gui.show_popup( + 'alert', + { + 'title': _t('Missing quantities'), + 'body': body, + }, + ); + } + } + }); + } + }) + } +); diff --git a/pos_require_product_quantity/views/assets.xml b/pos_require_product_quantity/views/assets.xml new file mode 100644 index 00000000..472192fc --- /dev/null +++ b/pos_require_product_quantity/views/assets.xml @@ -0,0 +1,8 @@ + + +