diff --git a/pos_barcode_rule_priced_with_change_rate/README.rst b/pos_barcode_rule_priced_with_change_rate/README.rst new file mode 100644 index 0000000000..f71787740a --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/README.rst @@ -0,0 +1,97 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +==================================================================== +Point of Sale - New barcode rule for priced product with change rate +==================================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:069fed6da59ff6b394529bafc4c3dcea82432135a03d961bc393f7b6daa2f261 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/license-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/19.0/pos_barcode_rule_priced_with_change_rate + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-19-0/pos-19-0-pos_barcode_rule_priced_with_change_rate + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a barcode rule to allow scanning barcodes with encoded +prices, similar to the standard "Priced Product" rule, while converting +the price according to a configured exchange rate. + +**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 +------- + +* Camptocamp + +Contributors +------------ + +- Camptocamp + + - Camille Morand camille.morand@camptocamp.com + +- Trobz + + - Tris Doan tridm@trobz.com + +- Niravrathod + + - Nirav Rathod niravrathod473@gmail.com + +Other credits +------------- + + + +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_barcode_rule_priced_with_change_rate/__init__.py b/pos_barcode_rule_priced_with_change_rate/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_barcode_rule_priced_with_change_rate/__manifest__.py b/pos_barcode_rule_priced_with_change_rate/__manifest__.py new file mode 100644 index 0000000000..2a8164c752 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/__manifest__.py @@ -0,0 +1,22 @@ +{ + "name": "Point of Sale - New barcode rule for priced product with change rate", + "version": "19.0.1.0.0", + "category": "Sales/Point of Sale", + "summary": """ + Add a barcode rule to be able to scan a barcode with price encoded (as the + standard "Priced Product" rule), and convert the price according to a given + change rate. + """, + "author": "Odoo Community Association (OCA), Camptocamp", + "website": "https://github.com/OCA/pos", + "depends": ["point_of_sale"], + "data": ["views/res_config_settings_views.xml"], + "assets": { + "point_of_sale._assets_pos": [ + "pos_barcode_rule_priced_with_change_rate/static/src/**/*", + ], + }, + "installable": True, + "license": "AGPL-3", + "development_status": "Production/Stable", +} diff --git a/pos_barcode_rule_priced_with_change_rate/i18n/fr.po b/pos_barcode_rule_priced_with_change_rate/i18n/fr.po new file mode 100644 index 0000000000..296f751c07 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/i18n/fr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_barcode_rule_priced_with_change_rate +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-03-25 11:10+0000\n" +"PO-Revision-Date: 2025-03-25 11:10+0000\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_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_barcode_rule +msgid "Barcode Rule" +msgstr "Règle de code-barres" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_pos_config__change_rate_barcode +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_res_config_settings__change_rate_barcode +msgid "Change rate for barcode nomenclature" +msgstr "Taux de change pour Nomenclature codes-barres" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_res_config_settings +msgid "Config Settings" +msgstr "Paramètres de configuration" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configuration du point de vente" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields.selection,name:pos_barcode_rule_priced_with_change_rate.selection__barcode_rule__type__price_change_rate +msgid "Priced Product with Change Rate" +msgstr "Produit à prix fixe avec taux de change" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_barcode_rule__type +msgid "Type" +msgstr "" diff --git a/pos_barcode_rule_priced_with_change_rate/i18n/it.po b/pos_barcode_rule_priced_with_change_rate/i18n/it.po new file mode 100644 index 0000000000..7eec09e077 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/i18n/it.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_barcode_rule_priced_with_change_rate +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-04-11 14:54+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 5.10.4\n" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_barcode_rule +msgid "Barcode Rule" +msgstr "Regola codice a barre" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_pos_config__change_rate_barcode +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_res_config_settings__change_rate_barcode +msgid "Change rate for barcode nomenclature" +msgstr "Tasso di cambio per la nomenclatura codice a barre" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_pos_config +msgid "Point of Sale Configuration" +msgstr "Configurazione punto vendita" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields.selection,name:pos_barcode_rule_priced_with_change_rate.selection__barcode_rule__type__price_change_rate +msgid "Priced Product with Change Rate" +msgstr "Prodotto prezzato con tasso di cambio" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_barcode_rule__type +msgid "Type" +msgstr "Tipo" diff --git a/pos_barcode_rule_priced_with_change_rate/i18n/pos_barcode_rule_priced_with_change_rate.pot b/pos_barcode_rule_priced_with_change_rate/i18n/pos_barcode_rule_priced_with_change_rate.pot new file mode 100644 index 0000000000..c9ec319965 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/i18n/pos_barcode_rule_priced_with_change_rate.pot @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_barcode_rule_priced_with_change_rate +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_barcode_rule +msgid "Barcode Rule" +msgstr "" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_pos_config__change_rate_barcode +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_res_config_settings__change_rate_barcode +msgid "Change rate for barcode nomenclature" +msgstr "" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model,name:pos_barcode_rule_priced_with_change_rate.model_pos_config +msgid "Point of Sale Configuration" +msgstr "" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields.selection,name:pos_barcode_rule_priced_with_change_rate.selection__barcode_rule__type__price_change_rate +msgid "Priced Product with Change Rate" +msgstr "" + +#. module: pos_barcode_rule_priced_with_change_rate +#: model:ir.model.fields,field_description:pos_barcode_rule_priced_with_change_rate.field_barcode_rule__type +msgid "Type" +msgstr "" diff --git a/pos_barcode_rule_priced_with_change_rate/models/__init__.py b/pos_barcode_rule_priced_with_change_rate/models/__init__.py new file mode 100644 index 0000000000..898c1f8ca0 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/models/__init__.py @@ -0,0 +1,3 @@ +from . import barcode_rule +from . import pos_config +from . import res_config_settings diff --git a/pos_barcode_rule_priced_with_change_rate/models/barcode_rule.py b/pos_barcode_rule_priced_with_change_rate/models/barcode_rule.py new file mode 100644 index 0000000000..fc8b91be8f --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/models/barcode_rule.py @@ -0,0 +1,13 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class BarcodeRule(models.Model): + _inherit = "barcode.rule" + + type = fields.Selection( + selection_add=[("price_change_rate", "Priced Product with Change Rate")], + ondelete={"price_change_rate": "set default"}, + ) diff --git a/pos_barcode_rule_priced_with_change_rate/models/pos_config.py b/pos_barcode_rule_priced_with_change_rate/models/pos_config.py new file mode 100644 index 0000000000..c40f5b1934 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/models/pos_config.py @@ -0,0 +1,15 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + change_rate_barcode = fields.Float( + string="Change rate for barcode nomenclature", + help="Conversion rate applied to the price encoded in a barcode " + "when using the 'Priced Product with Change Rate' rule. " + "The scanned price is divided by this rate.", + ) diff --git a/pos_barcode_rule_priced_with_change_rate/models/res_config_settings.py b/pos_barcode_rule_priced_with_change_rate/models/res_config_settings.py new file mode 100644 index 0000000000..2d14aa4ef3 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/models/res_config_settings.py @@ -0,0 +1,12 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + change_rate_barcode = fields.Float( + related="pos_config_id.change_rate_barcode", readonly=False + ) diff --git a/pos_barcode_rule_priced_with_change_rate/pyproject.toml b/pos_barcode_rule_priced_with_change_rate/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_barcode_rule_priced_with_change_rate/readme/CONTRIBUTORS.md b/pos_barcode_rule_priced_with_change_rate/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..41dd5ee3f0 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/readme/CONTRIBUTORS.md @@ -0,0 +1,8 @@ +- Camptocamp + - Camille Morand + +- Trobz + - Tris Doan + +- Niravrathod + - Nirav Rathod \ No newline at end of file diff --git a/pos_barcode_rule_priced_with_change_rate/readme/CREDITS.md b/pos_barcode_rule_priced_with_change_rate/readme/CREDITS.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pos_barcode_rule_priced_with_change_rate/readme/DESCRIPTION.md b/pos_barcode_rule_priced_with_change_rate/readme/DESCRIPTION.md new file mode 100644 index 0000000000..233b6e91f7 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module adds a barcode rule to allow scanning barcodes with encoded prices, +similar to the standard "Priced Product" rule, while converting the price +according to a configured exchange rate. diff --git a/pos_barcode_rule_priced_with_change_rate/static/description/icon.png b/pos_barcode_rule_priced_with_change_rate/static/description/icon.png new file mode 100644 index 0000000000..1dcc49c24f Binary files /dev/null and b/pos_barcode_rule_priced_with_change_rate/static/description/icon.png differ diff --git a/pos_barcode_rule_priced_with_change_rate/static/description/index.html b/pos_barcode_rule_priced_with_change_rate/static/description/index.html new file mode 100644 index 0000000000..185cd4f408 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Point of Sale - New barcode rule for priced product with change rate

+ +

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

+

This module adds a barcode rule to allow scanning barcodes with encoded +prices, similar to the standard “Priced Product” rule, while converting +the price according to a configured exchange rate.

+

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

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+ +
+

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_barcode_rule_priced_with_change_rate/static/src/overrides/components/product_screen/product_screen.esm.js b/pos_barcode_rule_priced_with_change_rate/static/src/overrides/components/product_screen/product_screen.esm.js new file mode 100644 index 0000000000..c1e18410d2 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/static/src/overrides/components/product_screen/product_screen.esm.js @@ -0,0 +1,56 @@ +// Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +// License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import {ProductScreen} from "@point_of_sale/app/screens/product_screen/product_screen"; +import {patch} from "@web/core/utils/patch"; +import {useBarcodeReader} from "@point_of_sale/app/hooks/barcode_reader_hook"; + +patch(ProductScreen.prototype, { + setup() { + super.setup(...arguments); + useBarcodeReader({ + price_change_rate: this._onPriceChangeRateScan, + }); + }, + + /** + * Handle barcode scan for "Priced Product with Change Rate" rule. + * + * Reads the barcode the same way as the standard `price` type, + * then converts the encoded price according to the change rate + * configured in the POS settings before adding the product + * to the current order. + * + * @param {Object} code - Parsed barcode object from the nomenclature. + */ + async _onPriceChangeRateScan(code) { + const product = await this._getProductByBarcode(code); + + if (!product) { + this.sound.play("scan-error"); + this.barcodeReader.showNotFoundNotification(code); + return; + } + + const rate = this.pos.config.change_rate_barcode; + if (!rate || rate <= 0) { + this.sound.play("scan-error"); + return; + } + + this.sound.play("beep"); + const price = this.env.utils.roundCurrency(code.value / rate); + + await this.pos.addLineToCurrentOrder( + { + product_id: product, + product_tmpl_id: product.product_tmpl_id, + price_unit: price, + }, + {code}, + product.needToConfigure() + ); + this.numberBuffer.reset(); + this.showOptionalProductPopupIfNeeded(product); + }, +}); diff --git a/pos_barcode_rule_priced_with_change_rate/static/src/tours/pos_barcode_tour.esm.js b/pos_barcode_rule_priced_with_change_rate/static/src/tours/pos_barcode_tour.esm.js new file mode 100644 index 0000000000..70979d027a --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/static/src/tours/pos_barcode_tour.esm.js @@ -0,0 +1,20 @@ +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("pos_barcode_change_rate_tour", { + url: "/pos/ui", + steps: () => [ + { + content: "Wait for POS to load", + trigger: ".pos-content", + run: () => null, + }, + // We simulate a barcode scan by sending a barcode event manually or + // using the barcode service mock if available in tests. + // For simplicity, this is a placeholder for the scan interaction. + { + content: "Mock barcode scan", + trigger: ".pos-content", + run: () => null, + }, + ], +}); diff --git a/pos_barcode_rule_priced_with_change_rate/views/res_config_settings_views.xml b/pos_barcode_rule_priced_with_change_rate/views/res_config_settings_views.xml new file mode 100644 index 0000000000..615fdba968 --- /dev/null +++ b/pos_barcode_rule_priced_with_change_rate/views/res_config_settings_views.xml @@ -0,0 +1,22 @@ + + + + res.config.settings.view.form.inherit.pos_barcode_rule_priced_with_change_rate + res.config.settings + + + +
+
+
+
+
+