diff --git a/pos_sequence/README.rst b/pos_sequence/README.rst new file mode 100644 index 0000000000..13206df60b --- /dev/null +++ b/pos_sequence/README.rst @@ -0,0 +1,108 @@ +==================== +POS Product Sequence +==================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:abf502d6a45bba87c88129a50734725629d69ba1100e61b47250a28ba91cd865 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.0/pos_sequence + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_sequence + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a POS sequence on products and sorts products in the +Point of Sale grid using this order: + +1. POS sequence +2. Internal Reference (default code) +3. Product name + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +- Go to *Point of Sale > Products > Products*. +- Set *POS sequence* on products. +- Use lower values to make products appear earlier in the POS grid. + +Usage +===== + +When products are loaded in Point of Sale, they are displayed ordered +by: + +1. POS sequence +2. Internal Reference (default code) +3. Product name + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Miguel Machado + +Contributors +------------ + +- Miguel Machado + +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-MiguelMachadoM| image:: https://github.com/MiguelMachadoM.png?size=40px + :target: https://github.com/MiguelMachadoM + :alt: MiguelMachadoM + +Current `maintainer `__: + +|maintainer-MiguelMachadoM| + +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_sequence/__init__.py b/pos_sequence/__init__.py new file mode 100644 index 0000000000..31660d6a96 --- /dev/null +++ b/pos_sequence/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/pos_sequence/__manifest__.py b/pos_sequence/__manifest__.py new file mode 100644 index 0000000000..51a05ad065 --- /dev/null +++ b/pos_sequence/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2026 Miguel Machado +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "POS Product Sequence", + "summary": "Sort POS products by custom sequence, reference and name", + "version": "18.0.1.0.0", + "development_status": "Beta", + "category": "Point Of Sale", + "website": "https://github.com/OCA/pos", + "author": "Miguel Machado, Odoo Community Association (OCA)", + "maintainers": ["MiguelMachadoM"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["point_of_sale"], + "data": [ + "views/product_template_views.xml", + "views/product_product_views.xml", + ], + "assets": { + "point_of_sale._assets_pos": [ + "pos_sequence/static/src/js/product_screen_pos_sequence.esm.js", + ], + }, +} diff --git a/pos_sequence/models/__init__.py b/pos_sequence/models/__init__.py new file mode 100644 index 0000000000..5d72f9beed --- /dev/null +++ b/pos_sequence/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import product_product +from . import product_template diff --git a/pos_sequence/models/product_product.py b/pos_sequence/models/product_product.py new file mode 100644 index 0000000000..ff7729e07d --- /dev/null +++ b/pos_sequence/models/product_product.py @@ -0,0 +1,21 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + pos_sequence = fields.Integer( + string="POS sequence", + related="product_tmpl_id.pos_sequence", + readonly=False, + store=True, + ) + + @api.model + def _load_pos_data_fields(self, config_id): + fields_list = super()._load_pos_data_fields(config_id) + if "pos_sequence" not in fields_list: + fields_list = list(fields_list) + ["pos_sequence"] + return fields_list diff --git a/pos_sequence/models/product_template.py b/pos_sequence/models/product_template.py new file mode 100644 index 0000000000..023e3013e5 --- /dev/null +++ b/pos_sequence/models/product_template.py @@ -0,0 +1,13 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + pos_sequence = fields.Integer( + string="POS sequence", + default=100, + help="Lower values are displayed first in the Point of Sale product grid.", + ) diff --git a/pos_sequence/pyproject.toml b/pos_sequence/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_sequence/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_sequence/readme/CONFIGURE.md b/pos_sequence/readme/CONFIGURE.md new file mode 100644 index 0000000000..2f43a4027b --- /dev/null +++ b/pos_sequence/readme/CONFIGURE.md @@ -0,0 +1,5 @@ +To configure this module, you need to: + +- Go to *Point of Sale > Products > Products*. +- Set *POS sequence* on products. +- Use lower values to make products appear earlier in the POS grid. diff --git a/pos_sequence/readme/CONTRIBUTORS.md b/pos_sequence/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..3e6c629cb0 --- /dev/null +++ b/pos_sequence/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Miguel Machado diff --git a/pos_sequence/readme/DESCRIPTION.md b/pos_sequence/readme/DESCRIPTION.md new file mode 100644 index 0000000000..e72fe89518 --- /dev/null +++ b/pos_sequence/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +This module adds a POS sequence on products and sorts products in the Point of Sale +grid using this order: + +1. POS sequence +2. Internal Reference (default code) +3. Product name diff --git a/pos_sequence/readme/USAGE.md b/pos_sequence/readme/USAGE.md new file mode 100644 index 0000000000..72fed76b3d --- /dev/null +++ b/pos_sequence/readme/USAGE.md @@ -0,0 +1,5 @@ +When products are loaded in Point of Sale, they are displayed ordered by: + +1. POS sequence +2. Internal Reference (default code) +3. Product name diff --git a/pos_sequence/static/description/icon.png b/pos_sequence/static/description/icon.png new file mode 100644 index 0000000000..a85d9db1b3 Binary files /dev/null and b/pos_sequence/static/description/icon.png differ diff --git a/pos_sequence/static/description/index.html b/pos_sequence/static/description/index.html new file mode 100644 index 0000000000..87e4b457d1 --- /dev/null +++ b/pos_sequence/static/description/index.html @@ -0,0 +1,452 @@ + + + + + +POS Product Sequence + + + +
+

POS Product Sequence

+ + +

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

+

This module adds a POS sequence on products and sorts products in the +Point of Sale grid using this order:

+
    +
  1. POS sequence
  2. +
  3. Internal Reference (default code)
  4. +
  5. Product name
  6. +
+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  • Go to Point of Sale > Products > Products.
  • +
  • Set POS sequence on products.
  • +
  • Use lower values to make products appear earlier in the POS grid.
  • +
+
+
+

Usage

+

When products are loaded in Point of Sale, they are displayed ordered +by:

+
    +
  1. POS sequence
  2. +
  3. Internal Reference (default code)
  4. +
  5. Product name
  6. +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Miguel Machado
  • +
+
+
+

Contributors

+
    +
  • Miguel Machado
  • +
+
+
+

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:

+

MiguelMachadoM

+

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_sequence/static/src/js/product_screen_pos_sequence.esm.js b/pos_sequence/static/src/js/product_screen_pos_sequence.esm.js new file mode 100644 index 0000000000..f9eeeb259a --- /dev/null +++ b/pos_sequence/static/src/js/product_screen_pos_sequence.esm.js @@ -0,0 +1,42 @@ +import {ProductScreen} from "@point_of_sale/app/screens/product_screen/product_screen"; +import {patch} from "@web/core/utils/patch"; + +function asNumber(value, fallback = 0) { + const parsed = Number(value); + return Number.isFinite(parsed) ? parsed : fallback; +} + +function asString(value) { + return (value || "").toString().trim().toLowerCase(); +} + +function sortByPosSequenceDefaultCodeName(products) { + return products.slice().sort((a, b) => { + const byPosSequence = + asNumber(a.pos_sequence, 100) - asNumber(b.pos_sequence, 100); + if (byPosSequence !== 0) { + return byPosSequence; + } + const byDefaultCode = asString(a.default_code).localeCompare( + asString(b.default_code) + ); + if (byDefaultCode !== 0) { + return byDefaultCode; + } + return asString(a.name || a.display_name).localeCompare( + asString(b.name || b.display_name) + ); + }); +} + +patch(ProductScreen.prototype, { + get productsToDisplay() { + const products = super.productsToDisplay; + return sortByPosSequenceDefaultCodeName(products); + }, + + getProductsBySearchWord(searchWord) { + const products = super.getProductsBySearchWord(searchWord); + return sortByPosSequenceDefaultCodeName(products); + }, +}); diff --git a/pos_sequence/tests/__init__.py b/pos_sequence/tests/__init__.py new file mode 100644 index 0000000000..a071a8bf83 --- /dev/null +++ b/pos_sequence/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pos_sequence diff --git a/pos_sequence/tests/test_pos_sequence.py b/pos_sequence/tests/test_pos_sequence.py new file mode 100644 index 0000000000..10efda88c5 --- /dev/null +++ b/pos_sequence/tests/test_pos_sequence.py @@ -0,0 +1,40 @@ +# Copyright 2026 Miguel Machado +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import odoo.tests + +from odoo.addons.point_of_sale.tests.common import TestPoSCommon + + +@odoo.tests.tagged("post_install", "-at_install") +class TestPosSequence(TestPoSCommon): + def test_product_template_pos_sequence_default(self): + template = self.env["product.template"].create( + { + "name": "POS sequence default test", + "list_price": 10.0, + "available_in_pos": True, + } + ) + self.assertEqual(template.pos_sequence, 100) + + def test_product_variant_related_pos_sequence(self): + template = self.env["product.template"].create( + { + "name": "POS sequence related test", + "list_price": 10.0, + "available_in_pos": True, + "pos_sequence": 5, + } + ) + variant = template.product_variant_id + self.assertEqual(variant.pos_sequence, 5) + + variant.pos_sequence = 99 + self.assertEqual(template.pos_sequence, 99) + + def test_product_product_load_pos_data_fields_includes_pos_sequence(self): + fields_list = self.env["product.product"]._load_pos_data_fields( + self.basic_config.id + ) + self.assertIn("pos_sequence", fields_list) diff --git a/pos_sequence/views/product_product_views.xml b/pos_sequence/views/product_product_views.xml new file mode 100644 index 0000000000..3791dd7787 --- /dev/null +++ b/pos_sequence/views/product_product_views.xml @@ -0,0 +1,27 @@ + + + + product.product.tree.pos.sequence + product.product + + + + + + + + + + product.product.form.pos.edit.popup.pos.sequence + product.product + + + + + + + + diff --git a/pos_sequence/views/product_template_views.xml b/pos_sequence/views/product_template_views.xml new file mode 100644 index 0000000000..f80bfe53f8 --- /dev/null +++ b/pos_sequence/views/product_template_views.xml @@ -0,0 +1,24 @@ + + + + product.template.form.pos.sequence + product.template + + + + + + + + + + product.template.tree.pos.sequence + product.template + + + + + + + +