diff --git a/pos_product_multi_barcode/README.rst b/pos_product_multi_barcode/README.rst new file mode 100644 index 0000000000..edf2732a67 --- /dev/null +++ b/pos_product_multi_barcode/README.rst @@ -0,0 +1,86 @@ +========================= +PoS Product multi barcode +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ec69d44c258170894cd14a9d9172b77a3b8dbf5068114d61a37e2cd2b3512e49 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_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-16-0/pos-16-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=16.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 +~~~~~~~~~~~~ + +* Ooops404 + + * 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..ce71bfc533 --- /dev/null +++ b/pos_product_multi_barcode/__manifest__.py @@ -0,0 +1,23 @@ +{ + "name": "PoS Product multi barcode", + "summary": "Make product multi barcodes usable in the point of sale", + "version": "16.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_product_multi_barcode/static/src/js/db.js", + ] + }, + "demo": [], + "qweb": [], +} diff --git a/pos_product_multi_barcode/i18n/it.po b/pos_product_multi_barcode/i18n/it.po new file mode 100644 index 0000000000..8a1c8e6423 --- /dev/null +++ b/pos_product_multi_barcode/i18n/it.po @@ -0,0 +1,42 @@ +# 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-03-16 16:32+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.14.1\n" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product__id +msgid "ID" +msgstr "ID" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_product_product +msgid "Product" +msgstr "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" 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..8b0f4d1e05 --- /dev/null +++ b/pos_product_multi_barcode/i18n/pos_product_multi_barcode.pot @@ -0,0 +1,39 @@ +# 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" +"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.fields,field_description:pos_product_multi_barcode.field_product_product__display_name +msgid "Display Name" +msgstr "" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product__id +msgid "ID" +msgstr "" + +#. module: pos_product_multi_barcode +#: model:ir.model.fields,field_description:pos_product_multi_barcode.field_product_product____last_update +msgid "Last Modified on" +msgstr "" + +#. module: pos_product_multi_barcode +#: model:ir.model,name:pos_product_multi_barcode.model_product_product +msgid "Product" +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/readme/CONTRIBUTORS.rst b/pos_product_multi_barcode/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..aadead0825 --- /dev/null +++ b/pos_product_multi_barcode/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ + * Pierrick Brun + * Ilyas + * Nguyen Minh Chien diff --git a/pos_product_multi_barcode/readme/CREDITS.rst b/pos_product_multi_barcode/readme/CREDITS.rst new file mode 100644 index 0000000000..a5c8f66b93 --- /dev/null +++ b/pos_product_multi_barcode/readme/CREDITS.rst @@ -0,0 +1 @@ +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.rst b/pos_product_multi_barcode/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..500714250e --- /dev/null +++ b/pos_product_multi_barcode/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +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 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..585d65dbd1 --- /dev/null +++ b/pos_product_multi_barcode/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +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/js/db.js b/pos_product_multi_barcode/static/src/js/db.js new file mode 100644 index 0000000000..075ed68c5c --- /dev/null +++ b/pos_product_multi_barcode/static/src/js/db.js @@ -0,0 +1,32 @@ +odoo.define("pos_product_multi_barcode.db", function (require) { + "use strict"; + + var PosDB = require("point_of_sale.DB"); + + PosDB.include({ + _product_search_string: function (product) { + var str = this._super(product); + if (product.barcodes_json) { + const barcodes = JSON.parse(product.barcodes_json).join(","); + str = str.replace("\n", "|" + barcodes) + "\n"; + } + return str; + }, + add_products: function (products) { + var res = this._super(products); + var self = this; + + if (!products instanceof Array) { + products = [products]; + } + products.forEach(function (product) { + var barcodes = JSON.parse(product.barcodes_json); + + barcodes.forEach(function (barcode) { + self.product_by_barcode[barcode] = product; + }); + }); + return res; + }, + }); +}); diff --git a/setup/pos_product_multi_barcode/odoo/addons/pos_product_multi_barcode b/setup/pos_product_multi_barcode/odoo/addons/pos_product_multi_barcode new file mode 120000 index 0000000000..26ac16822b --- /dev/null +++ b/setup/pos_product_multi_barcode/odoo/addons/pos_product_multi_barcode @@ -0,0 +1 @@ +../../../../pos_product_multi_barcode \ No newline at end of file diff --git a/setup/pos_product_multi_barcode/setup.py b/setup/pos_product_multi_barcode/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/pos_product_multi_barcode/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)