diff --git a/pos_product_sequence/README.rst b/pos_product_sequence/README.rst new file mode 100644 index 0000000000..aba120e5f9 --- /dev/null +++ b/pos_product_sequence/README.rst @@ -0,0 +1,96 @@ +====================== +POS - Product Sequence +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/16.0/pos_product_sequence + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_product_sequence + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/pos&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allow user show the product in POS sequence + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Configure POS Sequence on product +#. Open the POS Session you cans see product order + +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 +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Sandip Vyas + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Open Source Integrators + +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. + +.. |maintainer-ursais| image:: https://github.com/ursais.png?size=40px + :target: https://github.com/ursais + :alt: ursais + +Current `maintainer `__: + +|maintainer-ursais| + +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_product_sequence/__init__.py b/pos_product_sequence/__init__.py new file mode 100644 index 0000000000..ecd4f0837c --- /dev/null +++ b/pos_product_sequence/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/pos_product_sequence/__manifest__.py b/pos_product_sequence/__manifest__.py new file mode 100644 index 0000000000..7837bac821 --- /dev/null +++ b/pos_product_sequence/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "POS - Product Sequence", + "version": "16.0.1.0.0", + "summary": "Manage Product sequence in Point Of Sale", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Point of Sale", + "maintainer": "Open Source Integrators", + "website": "https://github.com/OCA/pos", + "depends": ["point_of_sale"], + "data": ["views/product_view.xml"], + "assets": { + "point_of_sale.assets": [ + "pos_product_sequence/static/src/js/**/*.js", + ], + }, + "maintainers": ["ursais"], + "installable": True, +} diff --git a/pos_product_sequence/models/__init__.py b/pos_product_sequence/models/__init__.py new file mode 100644 index 0000000000..8f29dbd25a --- /dev/null +++ b/pos_product_sequence/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import product_template +from . import pos_session diff --git a/pos_product_sequence/models/pos_session.py b/pos_product_sequence/models/pos_session.py new file mode 100644 index 0000000000..1317659d30 --- /dev/null +++ b/pos_product_sequence/models/pos_session.py @@ -0,0 +1,13 @@ +# Copyright (C) 2022 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def _loader_params_product_product(self): + result = super()._loader_params_product_product() + result["search_params"]["fields"].append("pos_sequence") + return result diff --git a/pos_product_sequence/models/product_template.py b/pos_product_sequence/models/product_template.py new file mode 100644 index 0000000000..cc54c4920c --- /dev/null +++ b/pos_product_sequence/models/product_template.py @@ -0,0 +1,28 @@ +# Copyright (C) 2023 Open Source Integrators (https://www.opensourceintegrators.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + pos_sequence = fields.Integer( + "POS Sequence", + help="Determine the display order in the Point of Sale", + default=lambda self: self._default_pos_sequence(), + copy=False, + ) + + def _default_pos_sequence(self): + """We want new product to be the last (highest seq). + Every product should ideally have an unique sequence. + Default sequence (10000) should only be used for DB first product. + As we don't resequence the whole tree (as `sequence` does), this field + might have negative value. + """ + self._cr.execute("SELECT MAX(pos_sequence) FROM %s" % self._table) + max_sequence = self._cr.fetchone()[0] + if max_sequence is None: + return 10000 + return max_sequence + 5 diff --git a/pos_product_sequence/readme/CONTRIBUTORS.rst b/pos_product_sequence/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..b7be22b0cc --- /dev/null +++ b/pos_product_sequence/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sandip Vyas diff --git a/pos_product_sequence/readme/CREDITS.rst b/pos_product_sequence/readme/CREDITS.rst new file mode 100644 index 0000000000..0eff0acf4e --- /dev/null +++ b/pos_product_sequence/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Open Source Integrators diff --git a/pos_product_sequence/readme/DESCRIPTION.rst b/pos_product_sequence/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..ae72626fc6 --- /dev/null +++ b/pos_product_sequence/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allow user show the product in POS sequence diff --git a/pos_product_sequence/readme/USAGE.rst b/pos_product_sequence/readme/USAGE.rst new file mode 100644 index 0000000000..2c39fa5f25 --- /dev/null +++ b/pos_product_sequence/readme/USAGE.rst @@ -0,0 +1,4 @@ +To use this module, you need to: + +#. Configure POS Sequence on product +#. Open the POS Session you cans see product order diff --git a/pos_product_sequence/static/description/icon.png b/pos_product_sequence/static/description/icon.png new file mode 100644 index 0000000000..85d01763f3 Binary files /dev/null and b/pos_product_sequence/static/description/icon.png differ diff --git a/pos_product_sequence/static/description/index.html b/pos_product_sequence/static/description/index.html new file mode 100644 index 0000000000..5bb37bc736 --- /dev/null +++ b/pos_product_sequence/static/description/index.html @@ -0,0 +1,438 @@ + + + + + + +POS - Product Sequence + + + +
+

POS - Product Sequence

+ + +

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

+

This module allow user show the product in POS sequence

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Configure POS Sequence on product
  2. +
  3. Open the POS Session you cans see product order
  4. +
+
+
+

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

+
    +
  • Open Source Integrators
  • +
+
+ +
+

Other credits

+

The development of this module has been financially supported by:

+ +
+
+

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.

+

Current maintainer:

+

ursais

+

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_product_sequence/static/src/js/ProductsWidget.esm.js b/pos_product_sequence/static/src/js/ProductsWidget.esm.js new file mode 100644 index 0000000000..a17df7ab6f --- /dev/null +++ b/pos_product_sequence/static/src/js/ProductsWidget.esm.js @@ -0,0 +1,15 @@ +/** @odoo-module **/ + +import ProductsWidget from "point_of_sale.ProductsWidget"; +import Registries from "point_of_sale.Registries"; + +const SequenceProductsWidget = (ProductsWidget) => + class SequenceProductsWidget extends ProductsWidget { + get productsToDisplay() { + return super.productsToDisplay.sort( + (a, b) => a.pos_sequence - b.pos_sequence + ); + } + }; + +Registries.Component.extend(ProductsWidget, SequenceProductsWidget); diff --git a/pos_product_sequence/views/product_view.xml b/pos_product_sequence/views/product_view.xml new file mode 100644 index 0000000000..18b235b255 --- /dev/null +++ b/pos_product_sequence/views/product_view.xml @@ -0,0 +1,13 @@ + + + + product.template.product.pos.form + product.template + + + + + + + + diff --git a/setup/pos_product_sequence/odoo/addons/pos_product_sequence b/setup/pos_product_sequence/odoo/addons/pos_product_sequence new file mode 120000 index 0000000000..082bf9cc19 --- /dev/null +++ b/setup/pos_product_sequence/odoo/addons/pos_product_sequence @@ -0,0 +1 @@ +../../../../pos_product_sequence \ No newline at end of file diff --git a/setup/pos_product_sequence/setup.py b/setup/pos_product_sequence/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pos_product_sequence/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)