diff --git a/pos_odoo_driver_device_list/README.rst b/pos_odoo_driver_device_list/README.rst new file mode 100644 index 0000000..e69de29 diff --git a/pos_odoo_driver_device_list/__init__.py b/pos_odoo_driver_device_list/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/pos_odoo_driver_device_list/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_odoo_driver_device_list/__manifest__.py b/pos_odoo_driver_device_list/__manifest__.py new file mode 100644 index 0000000..780b3b4 --- /dev/null +++ b/pos_odoo_driver_device_list/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Point of Sale - Devices List (odoo-pos-driver)", + "version": "16.0.1.0.0", + "category": "Point Of Sale", + "summary": "Get devices information from odoo-pos-driver library", + "author": "GRAP", + "website": "https://github.com/grap/odoo-addons-pos", + "license": "AGPL-3", + "depends": ["point_of_sale"], + "assets": { + "point_of_sale.assets": [ + "pos_odoo_driver_device_list/static/src/js/devices.esm.js", + ], + }, + "data": [ + "views/view_pos_device.xml", + "security/ir.model.access.csv", + ], + "installable": True, +} diff --git a/pos_odoo_driver_device_list/i18n/fr.po b/pos_odoo_driver_device_list/i18n/fr.po new file mode 100644 index 0000000..e69de29 diff --git a/pos_odoo_driver_device_list/models/__init__.py b/pos_odoo_driver_device_list/models/__init__.py new file mode 100644 index 0000000..9044dab --- /dev/null +++ b/pos_odoo_driver_device_list/models/__init__.py @@ -0,0 +1,2 @@ +from . import pos_config +from . import pos_device diff --git a/pos_odoo_driver_device_list/models/pos_config.py b/pos_odoo_driver_device_list/models/pos_config.py new file mode 100644 index 0000000..f14a042 --- /dev/null +++ b/pos_odoo_driver_device_list/models/pos_config.py @@ -0,0 +1,11 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class PosConfig(models.Model): + _inherit = "pos.config" + + device_ids = fields.One2many(comodel_name="pos.device", inverse_name="config_id") diff --git a/pos_odoo_driver_device_list/models/pos_device.py b/pos_odoo_driver_device_list/models/pos_device.py new file mode 100644 index 0000000..86d3b2d --- /dev/null +++ b/pos_odoo_driver_device_list/models/pos_device.py @@ -0,0 +1,31 @@ +# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class PosDevice(models.Model): + _name = "pos.device" + _description = "Point of Sale Devices" + + config_id = fields.Many2one(comodel_name="pos.config") + + company_id = fields.Many2one( + comodel_name="res.company", default=lambda x: x._default_company_id() + ) + + name = fields.Char(readonly=True) + + product_name = fields.Char(readonly=True) + + vendor_product_code = fields.Char(readonly=True) + + serial_number = fields.Char(readonly=True) + + manufacturer = fields.Char(readonly=True) + + last_connexion_date = fields.Datetime(readonly=True) + + def _default_company_id(self): + return self.env.company diff --git a/pos_odoo_driver_device_list/readme/CONTRIBUTORS.rst b/pos_odoo_driver_device_list/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..ae6f43a --- /dev/null +++ b/pos_odoo_driver_device_list/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sylvain LE GAL (https://twitter.com/legalsylvain) diff --git a/pos_odoo_driver_device_list/readme/DESCRIPTION.rst b/pos_odoo_driver_device_list/readme/DESCRIPTION.rst new file mode 100644 index 0000000..e619d9b --- /dev/null +++ b/pos_odoo_driver_device_list/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module extends the Point of Sale odoo module, to add compatibility with the ``odoo-pos-driver`` +python library. + +It will store connected devices information in Odoo for analysis. diff --git a/pos_odoo_driver_device_list/readme/USAGE.rst b/pos_odoo_driver_device_list/readme/USAGE.rst new file mode 100644 index 0000000..2104a27 --- /dev/null +++ b/pos_odoo_driver_device_list/readme/USAGE.rst @@ -0,0 +1,9 @@ +* Open the Point of sale, with usb devices connected. + +* Close the point of sale. + +* Go to " / Devices". + +you can see the devices information, with last usage date. + +.. figure:: ../static/img/pos_device_tree.png diff --git a/pos_odoo_driver_device_list/security/ir.model.access.csv b/pos_odoo_driver_device_list/security/ir.model.access.csv new file mode 100644 index 0000000..bc7e685 --- /dev/null +++ b/pos_odoo_driver_device_list/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_pos_device_user,access_pos_device_user,pos_odoo_driver_device_list.model_pos_device,point_of_sale.group_pos_user,1,1,1,0 +access_pos_device_manager,access_pos_device_manager,pos_odoo_driver_device_list.model_pos_device,base.group_system,1,1,1,1 diff --git a/pos_odoo_driver_device_list/static/description/pos_front_end.png b/pos_odoo_driver_device_list/static/description/pos_front_end.png new file mode 100644 index 0000000..56f4ce2 Binary files /dev/null and b/pos_odoo_driver_device_list/static/description/pos_front_end.png differ diff --git a/pos_odoo_driver_device_list/static/description/pos_payment_method_form.png b/pos_odoo_driver_device_list/static/description/pos_payment_method_form.png new file mode 100644 index 0000000..e15ed11 Binary files /dev/null and b/pos_odoo_driver_device_list/static/description/pos_payment_method_form.png differ diff --git a/pos_odoo_driver_device_list/static/src/js/devices.esm.js b/pos_odoo_driver_device_list/static/src/js/devices.esm.js new file mode 100644 index 0000000..97e384f --- /dev/null +++ b/pos_odoo_driver_device_list/static/src/js/devices.esm.js @@ -0,0 +1,27 @@ +// Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) +// @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +odoo.define("pos_odoo_driver_device_list.devices", function (require) { + + var ProxyDevice = require("point_of_sale.devices").ProxyDevice; + + var set_connection_status_super = ProxyDevice.prototype.set_connection_status; + + ProxyDevice.prototype.set_connection_status = function (status, drivers, msg='') { + if (status === 'connected' && drivers !== undefined) { + var old_drivers = this.get('status').drivers; + var new_drivers = drivers ; + if (JSON.stringify(new_drivers) !== JSON.stringify(old_drivers)) { + // TODO + // Send a message to the backoffice + console.log("CHANGED"); + console.log("old_drivers", old_drivers); + console.log("new_drivers", new_drivers); + } + + } + set_connection_status_super.call(this, status, drivers, msg); + }; + +}); diff --git a/pos_odoo_driver_device_list/views/view_pos_device.xml b/pos_odoo_driver_device_list/views/view_pos_device.xml new file mode 100644 index 0000000..4893483 --- /dev/null +++ b/pos_odoo_driver_device_list/views/view_pos_device.xml @@ -0,0 +1,25 @@ + + + + + + pos.device + + + + + + + + + + + + + + + diff --git a/setup/.setuptools-odoo-make-default-ignore b/setup/.setuptools-odoo-make-default-ignore new file mode 100644 index 0000000..207e615 --- /dev/null +++ b/setup/.setuptools-odoo-make-default-ignore @@ -0,0 +1,2 @@ +# addons listed in this file are ignored by +# setuptools-odoo-make-default (one addon per line) diff --git a/setup/README b/setup/README new file mode 100644 index 0000000..a63d633 --- /dev/null +++ b/setup/README @@ -0,0 +1,2 @@ +To learn more about this directory, please visit +https://pypi.python.org/pypi/setuptools-odoo diff --git a/setup/pos_odoo_driver_device_list/odoo/addons/pos_odoo_driver_device_list b/setup/pos_odoo_driver_device_list/odoo/addons/pos_odoo_driver_device_list new file mode 120000 index 0000000..0ddc385 --- /dev/null +++ b/setup/pos_odoo_driver_device_list/odoo/addons/pos_odoo_driver_device_list @@ -0,0 +1 @@ +../../../../pos_odoo_driver_device_list \ No newline at end of file diff --git a/setup/pos_odoo_driver_device_list/setup.py b/setup/pos_odoo_driver_device_list/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/pos_odoo_driver_device_list/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)