diff --git a/pos_product_multi_barcode/README.rst b/pos_product_multi_barcode/README.rst new file mode 100644 index 0000000000..9967c98966 --- /dev/null +++ b/pos_product_multi_barcode/README.rst @@ -0,0 +1,87 @@ +========================= +PoS Product multi barcode +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bd0b5332354fadbeb36525abd18a74542e0b605196a0eda732e8a51084f5c9e3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/pos_product_multi_barcode + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_product_multi_barcode + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +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 + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Akretion + +Contributors +------------ + + - Pierrick Brun + - Ilyas + - Nguyen Minh Chien + +Other credits +------------- + +The migration of this module from 14.0 to 16.0 was financially supported +by Camptocamp + +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_product_multi_barcode/__init__.py b/pos_product_multi_barcode/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_product_multi_barcode/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_product_multi_barcode/__manifest__.py b/pos_product_multi_barcode/__manifest__.py new file mode 100644 index 0000000000..68131743fe --- /dev/null +++ b/pos_product_multi_barcode/__manifest__.py @@ -0,0 +1,21 @@ +{ + "name": "PoS Product multi barcode", + "summary": "Make product multi barcodes usable in the point of sale", + "version": "17.0.1.0.0", + "category": "Point of Sale", + "website": "https://github.com/OCA/pos", + "author": "Akretion, Odoo Community Association (OCA)", + "maintainer": "PierrickBrun", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "point_of_sale", + "product_multi_barcode", + ], + "assets": { + "point_of_sale._assets_pos": [ + "pos_product_multi_barcode/static/src/app/store/db.esm.js", + ] + }, +} diff --git a/pos_product_multi_barcode/i18n/es.po b/pos_product_multi_barcode/i18n/es.po new file mode 100644 index 0000000000..7d15cd7622 --- /dev/null +++ b/pos_product_multi_barcode/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_product_multi_barcode +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-08 22:35+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_pos_session +msgid "Point of Sale Session" +msgstr "Sesión del Punto de Venta" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_product_product +msgid "Product Variant" +msgstr "Variante del Producto" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product__barcodes_json +msgid "barcode list" +msgstr "lista de código de barras" diff --git a/pos_product_multi_barcode/i18n/it.po b/pos_product_multi_barcode/i18n/it.po new file mode 100644 index 0000000000..edeef49540 --- /dev/null +++ b/pos_product_multi_barcode/i18n/it.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_product_multi_barcode +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-23 19:35+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_pos_session +msgid "Point of Sale Session" +msgstr "Sessione punto vendita" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_product_product +msgid "Product Variant" +msgstr "Variante prodotto" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product__barcodes_json +msgid "barcode list" +msgstr "elenco codici a barre" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" + +#~ msgid "Product" +#~ msgstr "Prodotto" diff --git a/pos_product_multi_barcode/i18n/pos_product_multi_barcode.pot b/pos_product_multi_barcode/i18n/pos_product_multi_barcode.pot new file mode 100644 index 0000000000..0777394a0b --- /dev/null +++ b/pos_product_multi_barcode/i18n/pos_product_multi_barcode.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_product_multi_barcode +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_pos_session +msgid "Point of Sale Session" +msgstr "" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product__barcodes_json +msgid "barcode list" +msgstr "" diff --git a/pos_product_multi_barcode/models/__init__.py b/pos_product_multi_barcode/models/__init__.py new file mode 100644 index 0000000000..4e2cc77c7a --- /dev/null +++ b/pos_product_multi_barcode/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_session +from . import product 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..629b93ce20 --- /dev/null +++ b/pos_product_multi_barcode/models/pos_session.py @@ -0,0 +1,12 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +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("barcodes_json") + return result diff --git a/pos_product_multi_barcode/models/product.py b/pos_product_multi_barcode/models/product.py new file mode 100644 index 0000000000..09aa3b39f5 --- /dev/null +++ b/pos_product_multi_barcode/models/product.py @@ -0,0 +1,21 @@ +# Copyright 2022 Akretion (https://www.akretion.com). +# @author Pierrick Brun +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import json + +from odoo import fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + # technical field used in POS frontend + barcodes_json = fields.Char( + "barcode list", readonly=True, compute="_compute_barcodes_json" + ) + + def _compute_barcodes_json(self): + for product in self: + barcodes = [barcode for barcode in product.mapped("barcode_ids.name")] + product.barcodes_json = json.dumps(barcodes) diff --git a/pos_product_multi_barcode/pyproject.toml b/pos_product_multi_barcode/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_product_multi_barcode/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_product_multi_barcode/readme/CONTRIBUTORS.md b/pos_product_multi_barcode/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..e7bb38cdc7 --- /dev/null +++ b/pos_product_multi_barcode/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +> - Pierrick Brun \ +> - Ilyas \ +> - Nguyen Minh Chien \ diff --git a/pos_product_multi_barcode/readme/CREDITS.md b/pos_product_multi_barcode/readme/CREDITS.md new file mode 100644 index 0000000000..44a6233517 --- /dev/null +++ b/pos_product_multi_barcode/readme/CREDITS.md @@ -0,0 +1,2 @@ +The migration of this module from 14.0 to 16.0 was financially supported +by Camptocamp diff --git a/pos_product_multi_barcode/readme/DESCRIPTION.md b/pos_product_multi_barcode/readme/DESCRIPTION.md new file mode 100644 index 0000000000..c004e16839 --- /dev/null +++ b/pos_product_multi_barcode/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module allows to use multiple barcode on a product from the PoS + +See + diff --git a/pos_product_multi_barcode/static/description/icon.png b/pos_product_multi_barcode/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/pos_product_multi_barcode/static/description/icon.png differ diff --git a/pos_product_multi_barcode/static/description/index.html b/pos_product_multi_barcode/static/description/index.html new file mode 100644 index 0000000000..ef58fff1cc --- /dev/null +++ b/pos_product_multi_barcode/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +PoS Product multi barcode + + + +
+

PoS Product multi barcode

+ + +

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

+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+
+ +
+
+
+

Other credits

+

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

+
+
+

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_product_multi_barcode/static/src/app/store/db.esm.js b/pos_product_multi_barcode/static/src/app/store/db.esm.js new file mode 100644 index 0000000000..93e9b58f66 --- /dev/null +++ b/pos_product_multi_barcode/static/src/app/store/db.esm.js @@ -0,0 +1,31 @@ +/** @odoo-module */ + +import {PosDB} from "@point_of_sale/app/store/db"; +import {patch} from "@web/core/utils/patch"; + +patch(PosDB.prototype, { + _product_search_string(product) { + var str = super._product_search_string(product); + if (product.barcodes_json) { + const barcodes = JSON.parse(product.barcodes_json).join(","); + str = str.replace("\n", "|" + barcodes) + "\n"; + } + return str; + }, + add_products(products) { + var res = super.add_products(products); + var self = this; + + products.forEach(function (product) { + var barcodes = JSON.parse(product.barcodes_json); + + barcodes.forEach(function (barcode) { + if (barcode in self.product_by_barcode) { + return; + } + self.product_by_barcode[barcode] = product; + }); + }); + return res; + }, +}); diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000000..fc5ec3038a --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-product_multi_barcode @ git+https://github.com/OCA/stock-logistics-barcode.git@refs/pull/686/head#subdirectory=product_multi_barcode