diff --git a/pos_product_multi_barcode/README.rst b/pos_product_multi_barcode/README.rst index 5fb7ecb68c..33955c8ed4 100644 --- a/pos_product_multi_barcode/README.rst +++ b/pos_product_multi_barcode/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - ========================= PoS Product multi barcode ========================= @@ -17,7 +13,7 @@ PoS Product multi barcode .. |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/license-AGPL--3-blue.png +.. |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 @@ -37,6 +33,10 @@ This module allows to use multiple barcode on a product from the PoS See https://github.com/OCA/stock-logistics-barcode/tree/14.0/product_multi_barcode +Barcode scanning is first resolved using the POS client-side indexed +products. If not found, it falls back to a backend search via +``pos.session.find_product_by_barcode``. + **Table of contents** .. contents:: @@ -66,6 +66,7 @@ Contributors - Pierrick Brun - Ilyas - Nguyen Minh Chien + - Patryk Pyczko Other credits ------------- diff --git a/pos_product_multi_barcode/models/__init__.py b/pos_product_multi_barcode/models/__init__.py index 9649db77a1..b9c6ba3aa0 100644 --- a/pos_product_multi_barcode/models/__init__.py +++ b/pos_product_multi_barcode/models/__init__.py @@ -1 +1,2 @@ from . import product +from . import pos_session diff --git a/pos_product_multi_barcode/models/pos_session.py b/pos_product_multi_barcode/models/pos_session.py new file mode 100644 index 0000000000..7bb90ffc1b --- /dev/null +++ b/pos_product_multi_barcode/models/pos_session.py @@ -0,0 +1,32 @@ +from odoo import models + + +class PosSession(models.Model): + _inherit = "pos.session" + + def find_product_by_barcode(self, barcode, config_id): + result = super().find_product_by_barcode(barcode, config_id) + + if result.get("product.product"): + return result + + product = self.env["product.product"].search( + [ + ("barcode_ids.name", "=", barcode), + ("sale_ok", "=", True), + ("available_in_pos", "=", True), + ], + limit=1, + ) + + if not product: + return result + + product_fields = self.env["product.product"]._load_pos_data_fields(config_id) + product_context = {**self.env.context, "display_default_code": False} + + return { + "product.product": product.with_context(**product_context).read( + product_fields, load=False + ) + } diff --git a/pos_product_multi_barcode/readme/CONTRIBUTORS.md b/pos_product_multi_barcode/readme/CONTRIBUTORS.md index e7bb38cdc7..40a2e1c19e 100644 --- a/pos_product_multi_barcode/readme/CONTRIBUTORS.md +++ b/pos_product_multi_barcode/readme/CONTRIBUTORS.md @@ -1,3 +1,4 @@ > - Pierrick Brun \ > - Ilyas \ > - Nguyen Minh Chien \ +> - Patryk Pyczko \ diff --git a/pos_product_multi_barcode/readme/DESCRIPTION.md b/pos_product_multi_barcode/readme/DESCRIPTION.md index c004e16839..286941c007 100644 --- a/pos_product_multi_barcode/readme/DESCRIPTION.md +++ b/pos_product_multi_barcode/readme/DESCRIPTION.md @@ -2,3 +2,5 @@ This module allows to use multiple barcode on a product from the PoS See + +Barcode scanning is first resolved using the POS client-side indexed products. If not found, it falls back to a backend search via `pos.session.find_product_by_barcode`. diff --git a/pos_product_multi_barcode/static/description/index.html b/pos_product_multi_barcode/static/description/index.html index 8df7794576..47412adc7a 100644 --- a/pos_product_multi_barcode/static/description/index.html +++ b/pos_product_multi_barcode/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +PoS Product multi barcode -
+
+

PoS Product multi barcode

- - -Odoo Community Association - -
-

PoS Product multi barcode

-

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

+

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

This module allows to use multiple barcode on a product from the PoS

See https://github.com/OCA/stock-logistics-barcode/tree/14.0/product_multi_barcode

+

Barcode scanning is first resolved using the POS client-side indexed +products. If not found, it falls back to a backend search via +pos.session.find_product_by_barcode.

Table of contents

    @@ -392,7 +390,7 @@

    PoS Product multi barcode

-

Bug Tracker

+

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 @@ -400,30 +398,31 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Akretion
-

Other credits

+

Other credits

The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -436,6 +435,5 @@

Maintainers

-