From c4772cac0781022a31c5a3fcec0ba536d34b8c0d Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Wed, 27 Feb 2019 15:17:47 +0100 Subject: [PATCH 1/5] [ADD] pos_require_product_quantity --- pos_require_product_quantity/__init__.py | 1 + pos_require_product_quantity/__openerp__.py | 24 ++++++++ .../models/__init__.py | 1 + .../models/pos_config.py | 15 +++++ .../static/src/js/pos.js | 59 +++++++++++++++++++ .../static/src/xml/templates.xml | 12 ++++ .../views/pos_config.xml | 15 +++++ 7 files changed, 127 insertions(+) create mode 100644 pos_require_product_quantity/__init__.py create mode 100644 pos_require_product_quantity/__openerp__.py create mode 100644 pos_require_product_quantity/models/__init__.py create mode 100644 pos_require_product_quantity/models/pos_config.py create mode 100644 pos_require_product_quantity/static/src/js/pos.js create mode 100644 pos_require_product_quantity/static/src/xml/templates.xml create mode 100644 pos_require_product_quantity/views/pos_config.xml 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/__openerp__.py b/pos_require_product_quantity/__openerp__.py new file mode 100644 index 00000000..6e340021 --- /dev/null +++ b/pos_require_product_quantity/__openerp__.py @@ -0,0 +1,24 @@ +# coding: utf-8 +# Copyright 2019 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": "9.0.0.1.0", + "author": "Coop IT Easy SCRLfs, Odoo Community Association (OCA)", + "website": "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', + 'static/src/xml/templates.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..99333c26 --- /dev/null +++ b/pos_require_product_quantity/models/pos_config.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 2016 Robin Keunen, Coop IT Easy SCRL fs +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + +from openerp 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/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/static/src/xml/templates.xml b/pos_require_product_quantity/static/src/xml/templates.xml new file mode 100644 index 00000000..a525a8be --- /dev/null +++ b/pos_require_product_quantity/static/src/xml/templates.xml @@ -0,0 +1,12 @@ + + + + + + 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 00000000..9f6a9aad --- /dev/null +++ b/pos_require_product_quantity/views/pos_config.xml @@ -0,0 +1,15 @@ + + + + + pos.config.form.view.inherit + pos.config + + + + + + + + + From d6ac98f1f514e207b60cb50c501d872258a6bc7d Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Mon, 11 Mar 2019 15:23:12 +0100 Subject: [PATCH 2/5] [ADD] pos_require_product_quantity: readme.rst --- pos_require_product_quantity/README.rst | 77 ++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 5 + .../static/description/index.html | 422 ++++++++++++++++++ 4 files changed, 505 insertions(+) create mode 100644 pos_require_product_quantity/README.rst create mode 100644 pos_require_product_quantity/readme/CONTRIBUTORS.rst create mode 100644 pos_require_product_quantity/readme/DESCRIPTION.rst create mode 100644 pos_require_product_quantity/static/description/index.html diff --git a/pos_require_product_quantity/README.rst b/pos_require_product_quantity/README.rst new file mode 100644 index 00000000..5450b195 --- /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/9.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-9-0/pos-9-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/9.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/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..2673bbe6 --- /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.

+
+
+
+ + From f9a6186cb19c84fe13e86501bda08f292cc5eb1b Mon Sep 17 00:00:00 2001 From: Manuel Claeys Bouuaert Date: Wed, 13 May 2020 16:52:46 +0200 Subject: [PATCH 3/5] [MIG] pos_require_product_quantity: v9 to v12 --- pos_require_product_quantity/README.rst | 10 +++++----- .../{__openerp__.py => __manifest__.py} | 7 +++---- .../models/pos_config.py | 7 +------ .../static/description/index.html | 8 ++++---- .../views/pos_config.xml | 18 ++++++++++++++---- 5 files changed, 27 insertions(+), 23 deletions(-) rename pos_require_product_quantity/{__openerp__.py => __manifest__.py} (83%) diff --git a/pos_require_product_quantity/README.rst b/pos_require_product_quantity/README.rst index 5450b195..3ce1e370 100644 --- a/pos_require_product_quantity/README.rst +++ b/pos_require_product_quantity/README.rst @@ -14,13 +14,13 @@ Require Product Quantity in POS :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/9.0/pos_require_product_quantity + :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-9-0/pos-9-0-pos_require_product_quantity + :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/9.0 + :target: https://runbot.odoo-community.org/runbot/184/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -42,7 +42,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -72,6 +72,6 @@ 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. +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/__openerp__.py b/pos_require_product_quantity/__manifest__.py similarity index 83% rename from pos_require_product_quantity/__openerp__.py rename to pos_require_product_quantity/__manifest__.py index 6e340021..ffecf2cd 100644 --- a/pos_require_product_quantity/__openerp__.py +++ b/pos_require_product_quantity/__manifest__.py @@ -1,12 +1,11 @@ -# coding: utf-8 -# Copyright 2019 Coop IT Easy SCRLfs +# 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": "9.0.0.1.0", + "version": "12.0.0.1.0", "author": "Coop IT Easy SCRLfs, Odoo Community Association (OCA)", - "website": "www.coopiteasy.be", + "website": "https://www.coopiteasy.be", "license": "AGPL-3", "category": "Point of Sale", "summary": """ diff --git a/pos_require_product_quantity/models/pos_config.py b/pos_require_product_quantity/models/pos_config.py index 99333c26..c64987c0 100644 --- a/pos_require_product_quantity/models/pos_config.py +++ b/pos_require_product_quantity/models/pos_config.py @@ -1,9 +1,4 @@ -# -*- coding: utf-8 -*- -# © 2016 Robin Keunen, Coop IT Easy SCRL fs -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - - -from openerp import models, fields +from odoo import models, fields class PosConfig(models.Model): diff --git a/pos_require_product_quantity/static/description/index.html b/pos_require_product_quantity/static/description/index.html index 2673bbe6..a7ece93b 100644 --- a/pos_require_product_quantity/static/description/index.html +++ b/pos_require_product_quantity/static/description/index.html @@ -3,7 +3,7 @@ - + Require Product Quantity in POS