diff --git a/pos_rfid/README.rst b/pos_rfid/README.rst new file mode 100644 index 0000000..82200b1 --- /dev/null +++ b/pos_rfid/README.rst @@ -0,0 +1,92 @@ +====================== +RFID adapter for POSes +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:82e8f0faf8fa78126dea845163c89a69a84ceb534bd749e3b299888bcfcfa196 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-it--projects--llc%2Fpos--addons-lightgray.png?logo=github + :target: https://github.com/it-projects-llc/pos-addons/tree/17.0/pos_rfid + :alt: it-projects-llc/pos-addons + +|badge1| |badge2| |badge3| + +Converts RFID scan result to a proper value. + +It's not possible to make similar module that depends on ``barcodes`` +only, because in some cases there is no way to automatically detect +shall code be translated or not. So in that cases we trigger several +events: with original code and with translated ones. + +Adapters +======== + +HEX to DEC +---------- + +E.g. ``9cc29d808 >> 042080000008`` + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +- Open "Point of Sale" app +- Open "Configutration" -> "Settings" +- Choose POS +- Enable "HEX Barcode" option + +Usage +===== + +- Open POS +- Scan RFID +- RESULT: POS reacts in the same way as if RFID was scanned via normal + RFID reader + +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 +------- + +* IT-Projects LLC + +Contributors +------------ + +- Ivan Yelizariev (https://github.com/yelizariev) +- Alexandr Kolusov (https://github.com/KolushovAlexandr) +- Artem Rafailov (https://github.com/Ommo73) +- Eugene Molotov (https://github.com/em230418) + +Maintainers +----------- + +This module is part of the `it-projects-llc/pos-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/pos_rfid/__init__.py b/pos_rfid/__init__.py new file mode 100644 index 0000000..f7209b1 --- /dev/null +++ b/pos_rfid/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import controllers diff --git a/pos_rfid/__manifest__.py b/pos_rfid/__manifest__.py new file mode 100644 index 0000000..57678c1 --- /dev/null +++ b/pos_rfid/__manifest__.py @@ -0,0 +1,24 @@ +{ + "name": """RFID adapter for POSes""", + "summary": """Converts RFID scan result to a proper value""", + "category": "Point of Sale", + "version": "17.0.0.9.0", + "author": "IT-Projects LLC", + "support": "apps@it-projects.info", + "website": "https://github.com/it-projects-llc/pos-addons", + "license": "LGPL-3", + "depends": [ + "point_of_sale", + ], + "assets": { + "point_of_sale._assets_pos": [ + "pos_rfid/static/src/**/*", + ], + }, + "data": [ + "views/res_config_settings_views.xml", + ], + "demo": [ + "data/point_of_sale_demo.xml", + ], +} diff --git a/pos_rfid/controllers/__init__.py b/pos_rfid/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/pos_rfid/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/pos_rfid/controllers/main.py b/pos_rfid/controllers/main.py new file mode 100644 index 0000000..a9e34bd --- /dev/null +++ b/pos_rfid/controllers/main.py @@ -0,0 +1,15 @@ +from odoo.http import request, route + +from odoo.addons.point_of_sale.controllers.main import PosController + + +class PosControllerRFID(PosController): + @route() + def pos_web(self, config_id=False, **kw): + res = super().pos_web(config_id, **kw) + if not config_id: + return res + + config = request.env["pos.config"].sudo().browse(int(config_id)) + res.qcontext["session_info"]["pos_hex_barcode"] = config.hex_barcode + return res diff --git a/pos_rfid/data/point_of_sale_demo.xml b/pos_rfid/data/point_of_sale_demo.xml new file mode 100644 index 0000000..17a3815 --- /dev/null +++ b/pos_rfid/data/point_of_sale_demo.xml @@ -0,0 +1,37 @@ + + + + + + + 042010000005 + + + + 042020000004 + + + + 042030000003 + + + + 042070000009 + + + + 042100000003 + + + + 042080000008 + + + + 042180000005 + + + + 041010000006 + + diff --git a/pos_rfid/migrations/17.0.1.0.0/post-migrate.py b/pos_rfid/migrations/17.0.1.0.0/post-migrate.py new file mode 100644 index 0000000..1f9d93e --- /dev/null +++ b/pos_rfid/migrations/17.0.1.0.0/post-migrate.py @@ -0,0 +1,2 @@ +def migrate(cr, installed_version): + cr.execute("UPDATE pos_config SET hex_barcode = pos_rfid") diff --git a/pos_rfid/models/__init__.py b/pos_rfid/models/__init__.py new file mode 100644 index 0000000..2b92809 --- /dev/null +++ b/pos_rfid/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_config +from . import res_config_settings diff --git a/pos_rfid/models/pos_config.py b/pos_rfid/models/pos_config.py new file mode 100644 index 0000000..928698d --- /dev/null +++ b/pos_rfid/models/pos_config.py @@ -0,0 +1,8 @@ +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + hex_barcode = fields.Boolean("HEX Barcode") + pos_rfid = fields.Boolean(deprecated=True) diff --git a/pos_rfid/models/res_config_settings.py b/pos_rfid/models/res_config_settings.py new file mode 100644 index 0000000..a0e6316 --- /dev/null +++ b/pos_rfid/models/res_config_settings.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_hex_barcode = fields.Boolean( + related="pos_config_id.hex_barcode", + readonly=False, + ) diff --git a/pos_rfid/pyproject.toml b/pos_rfid/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/pos_rfid/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_rfid/readme/CONFIGURE.md b/pos_rfid/readme/CONFIGURE.md new file mode 100644 index 0000000..92d387e --- /dev/null +++ b/pos_rfid/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +- Open "Point of Sale" app +- Open "Configutration" -> "Settings" +- Choose POS +- Enable "HEX Barcode" option diff --git a/pos_rfid/readme/CONTRIBUTORS.md b/pos_rfid/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..5b0764f --- /dev/null +++ b/pos_rfid/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Ivan Yelizariev (https://github.com/yelizariev) +- Alexandr Kolusov (https://github.com/KolushovAlexandr) +- Artem Rafailov (https://github.com/Ommo73) +- Eugene Molotov (https://github.com/em230418) diff --git a/pos_rfid/readme/DESCRIPTION.md b/pos_rfid/readme/DESCRIPTION.md new file mode 100644 index 0000000..21cc166 --- /dev/null +++ b/pos_rfid/readme/DESCRIPTION.md @@ -0,0 +1,12 @@ +Converts RFID scan result to a proper value. + +It's not possible to make similar module that depends on `barcodes` only, because in some cases there is no way to automatically detect shall code be translated or not. +So in that cases we trigger several events: with original code and with translated ones. + +Adapters +======== + +HEX to DEC +---------- + +E.g. `9cc29d808 >> 042080000008` diff --git a/pos_rfid/readme/USAGE.md b/pos_rfid/readme/USAGE.md new file mode 100644 index 0000000..33d441b --- /dev/null +++ b/pos_rfid/readme/USAGE.md @@ -0,0 +1,3 @@ +* Open POS +* Scan RFID +* RESULT: POS reacts in the same way as if RFID was scanned via normal RFID reader diff --git a/pos_rfid/static/description/icon.png b/pos_rfid/static/description/icon.png new file mode 100644 index 0000000..8a05828 Binary files /dev/null and b/pos_rfid/static/description/icon.png differ diff --git a/pos_rfid/static/description/index.html b/pos_rfid/static/description/index.html new file mode 100644 index 0000000..15b45a0 --- /dev/null +++ b/pos_rfid/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +RFID adapter for POSes + + + +
+

RFID adapter for POSes

+ + +

Beta License: LGPL-3 it-projects-llc/pos-addons

+

Converts RFID scan result to a proper value.

+

It’s not possible to make similar module that depends on barcodes +only, because in some cases there is no way to automatically detect +shall code be translated or not. So in that cases we trigger several +events: with original code and with translated ones.

+
+

Adapters

+
+

HEX to DEC

+

E.g. 9cc29d808 >> 042080000008

+

Table of contents

+
+
+
+

Configuration

+
    +
  • Open “Point of Sale” app
  • +
  • Open “Configutration” -> “Settings”
  • +
  • Choose POS
  • +
  • Enable “HEX Barcode” option
  • +
+
+
+

Usage

+
    +
  • Open POS
  • +
  • Scan RFID
  • +
  • RESULT: POS reacts in the same way as if RFID was scanned via normal +RFID reader
  • +
+
+
+

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

+
    +
  • IT-Projects LLC
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the it-projects-llc/pos-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/pos_rfid/static/src/app/barcode/barcode_reader_service.js b/pos_rfid/static/src/app/barcode/barcode_reader_service.js new file mode 100644 index 0000000..0c83b36 --- /dev/null +++ b/pos_rfid/static/src/app/barcode/barcode_reader_service.js @@ -0,0 +1,18 @@ +/** @odoo-module **/ + +import {BarcodeReader} from "@point_of_sale/app/barcode/barcode_reader_service"; +import {patch} from "@web/core/utils/patch"; +import {session} from "@web/session"; + +patch(BarcodeReader.prototype, { + _scan(code) { + if (code && session.pos_hex_barcode) { + let unhexed_code = parseInt(code, 16).toString(); + if (unhexed_code.length % 2) { + unhexed_code = "0" + unhexed_code; + } + return super._scan(unhexed_code); + } + return super._scan(code); + }, +}); diff --git a/pos_rfid/views/res_config_settings_views.xml b/pos_rfid/views/res_config_settings_views.xml new file mode 100644 index 0000000..d313427 --- /dev/null +++ b/pos_rfid/views/res_config_settings_views.xml @@ -0,0 +1,15 @@ + + + + res.config.settings.view.form.inherit.pos_rfid + res.config.settings + + + + + + + + + +