diff --git a/pos_payment_terminal_server/README.rst b/pos_payment_terminal_server/README.rst new file mode 100644 index 00000000..ea4d875c --- /dev/null +++ b/pos_payment_terminal_server/README.rst @@ -0,0 +1,89 @@ +=========================== +Pos Payment Terminal Server +=========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/8.0/pos_payment_terminal_server + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-8-0/pos-8-0-pos_payment_terminal_server + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/184/8.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +In some use cases, one may want to centralize the communication with +payment terminal on a same place +(e.g.: for deployment/infrastructure requirements). + +This module allows to create a new communication tunnel between +Odoo POS and a centralized payment terminal server. + +This implementation allows too to use classical 'PosBox' flow for other +interfaces (barcode, scale, printer, ...). + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +In each Point of Sale configuration, you have to check: + * Use payment terminal server + +Then, fill in the Payment Terminal Server field + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Denis Roussel + +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_payment_terminal_server/__init__.py b/pos_payment_terminal_server/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/pos_payment_terminal_server/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/pos_payment_terminal_server/__openerp__.py b/pos_payment_terminal_server/__openerp__.py new file mode 100644 index 00000000..605ca06b --- /dev/null +++ b/pos_payment_terminal_server/__openerp__.py @@ -0,0 +1,22 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Pos Payment Terminal Server', + 'summary': """ + Adds the possibility to manage several terminals with one server""", + 'version': '9.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/pos', + 'depends': [ + 'point_of_sale', + 'pos_payment_terminal', + ], + 'data': [ + 'views/pos_config.xml', + 'views/pos_payment_multi_terminal_template.xml', + ], + 'qweb': ['static/src/xml/pos_payment_terminal.xml'], + 'installable': True, +} diff --git a/pos_payment_terminal_server/models/__init__.py b/pos_payment_terminal_server/models/__init__.py new file mode 100644 index 00000000..db8634ad --- /dev/null +++ b/pos_payment_terminal_server/models/__init__.py @@ -0,0 +1 @@ +from . import pos_config diff --git a/pos_payment_terminal_server/models/pos_config.py b/pos_payment_terminal_server/models/pos_config.py new file mode 100644 index 00000000..840422f9 --- /dev/null +++ b/pos_payment_terminal_server/models/pos_config.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, fields, models + + +class PosConfig(models.Model): + + _inherit = 'pos.config' + + use_payment_terminal_server = fields.Boolean() + iface_payment_terminal_server = fields.Char() + iface_payment_terminal_id = fields.Char() + + @api.onchange('use_payment_terminal_server') + def onchange_use_payment_terminal_server(self): + if self.iface_payment_terminal_id: + self.iface_payment_terminal = False diff --git a/pos_payment_terminal_server/readme/CONTRIBUTORS.rst b/pos_payment_terminal_server/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..9179ee4b --- /dev/null +++ b/pos_payment_terminal_server/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Denis Roussel diff --git a/pos_payment_terminal_server/readme/DESCRIPTION.rst b/pos_payment_terminal_server/readme/DESCRIPTION.rst new file mode 100644 index 00000000..cf69bd53 --- /dev/null +++ b/pos_payment_terminal_server/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +In some use cases, one may want to centralize the communication with +payment terminal on a same place +(e.g.: for deployment/infrastructure requirements). + +This module allows to create a new communication tunnel between +Odoo POS and a centralized payment terminal server. + +This implementation allows too to use classical 'PosBox' flow for other +interfaces (barcode, scale, printer, ...). diff --git a/pos_payment_terminal_server/readme/USAGE.rst b/pos_payment_terminal_server/readme/USAGE.rst new file mode 100644 index 00000000..c51c9d94 --- /dev/null +++ b/pos_payment_terminal_server/readme/USAGE.rst @@ -0,0 +1,4 @@ +In each Point of Sale configuration, you have to check: + * Use payment terminal server + +Then, fill in the Payment Terminal Server field \ No newline at end of file diff --git a/pos_payment_terminal_server/static/description/icon.png b/pos_payment_terminal_server/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/pos_payment_terminal_server/static/description/icon.png differ diff --git a/pos_payment_terminal_server/static/description/index.html b/pos_payment_terminal_server/static/description/index.html new file mode 100644 index 00000000..152b1dfa --- /dev/null +++ b/pos_payment_terminal_server/static/description/index.html @@ -0,0 +1,437 @@ + + + + + + +Pos Payment Terminal Server + + + +
+

Pos Payment Terminal Server

+ + +

Beta License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runbot

+

In some use cases, one may want to centralize the communication with +payment terminal on a same place +(e.g.: for deployment/infrastructure requirements).

+

This module allows to create a new communication tunnel between +Odoo POS and a centralized payment terminal server.

+

This implementation allows too to use classical ‘PosBox’ flow for other +interfaces (barcode, scale, printer, …).

+

Table of contents

+ +
+

Usage

+
+
In each Point of Sale configuration, you have to check:
+
    +
  • Use payment terminal server
  • +
+
+
+

Then, fill in the Payment Terminal Server field

+
+
+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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_payment_terminal_server/static/src/js/chrome.js b/pos_payment_terminal_server/static/src/js/chrome.js new file mode 100644 index 00000000..d963d5fe --- /dev/null +++ b/pos_payment_terminal_server/static/src/js/chrome.js @@ -0,0 +1,66 @@ +/* + Copyright 2019 ACSONE SA/NV + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +*/ +odoo.define('pos_payment_terminal_server.chrome', function (require) { +"use strict"; + +var chrome = require('point_of_sale.chrome'); +var core = require('web.core'); + +var _t = core._t; + +var ProxyMultiStatusWidget = chrome.ProxyStatusWidget.extend({ + template: 'ProxyMultiStatusWidget', + set_terminal_status: function(status){ + if(status.status === 'connected'){ + var warning = false; + var msg = ''; + if(this.pos.config.use_payment_terminal_server){ + for (var driver in status.drivers){ + if (status.drivers[driver].is_terminal && status.drivers[driver].status != 'connected'){ + warning = true; + msg += _t('Payment server'); + } + } + } + msg = msg ? msg + ' ' + _t('Offline') : msg; + this.set_status(warning ? 'warning' : 'connected', msg); + }else{ + this.set_status(status.status,''); + } + }, + + start: function(){ + var self = this; + this.set_terminal_status(this.pos.terminal_server.get('status')); + this.pos.terminal_server.on('change:status',this,function(eh,status){ + self.set_terminal_status(status.newValue); + }); + this.$el.click(function(){ + self.pos.connect_to_terminal_server(); + }); + }, + +}); + +var Chrome = chrome.Chrome.include({ + init: function() { + var self = this; + this._super(arguments[0],{}); + this.widgets.push({ + 'name': 'proxy_multi_status', + 'widget': ProxyMultiStatusWidget, + 'append': '.pos-rightheader', + 'condition': function(){ return this.pos.config.use_payment_terminal_server; }, + }); + } + +}); + +return { + ProxyMultiStatusWidget: ProxyMultiStatusWidget, + Chrome: Chrome, + } + +}); diff --git a/pos_payment_terminal_server/static/src/js/devices.js b/pos_payment_terminal_server/static/src/js/devices.js new file mode 100644 index 00000000..5fb6565f --- /dev/null +++ b/pos_payment_terminal_server/static/src/js/devices.js @@ -0,0 +1,52 @@ +/* + Copyright 2019 ACSONE SA/NV + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +*/ +odoo.define('pos_payment_terminal_server.devices', function (require) { +"use strict"; +var devices = require('point_of_sale.devices'); +var core = require('web.core') + +var _super_proxydevice = devices.ProxyDevice.prototype; + +var ProxyTerminalDevice = devices.ProxyDevice.extend({ + update_transaction_data: function(line, data){ + this._super(line, data) + data.terminal_id = this.pos.config.iface_payment_terminal_id + }, + set_terminal_status: function(terminal_id){ + // Will get status from proxy for this terminal id + var self = this; + self.connection.rpc('/hw_proxy/status_json',{'terminal_id': terminal_id},{timeout:2500}) + .then(function(driver_status){ + for (var driver in driver_status){ + if (driver_status[driver].is_terminal && driver_status[driver].status === 'connected'){ + self.set_connection_status('connected',driver_status); + break; + } + } + },function(){ + if(self.get('status').status !== 'connecting'){ + self.set_connection_status('disconnected'); + } + }).always(function(){ + setTimeout(self.set_terminal_status.bind(self, terminal_id),5000); + }); + }, + // starts a loop that updates the connection status + keepalive: function(){ + var self = this; + if(!this.keptalive){ + if (self.pos.config.use_payment_terminal_server){ + this.keptalive = true; + this.set_terminal_status(self.pos.config.iface_payment_terminal_id); + } + } + }, +}); + +return { + ProxyTerminalDevice: ProxyTerminalDevice, +} + +}); diff --git a/pos_payment_terminal_server/static/src/js/models.js b/pos_payment_terminal_server/static/src/js/models.js new file mode 100644 index 00000000..cea0f6e4 --- /dev/null +++ b/pos_payment_terminal_server/static/src/js/models.js @@ -0,0 +1,43 @@ +/* + Copyright 2019 ACSONE SA/NV + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +*/ +odoo.define('pos_payment_terminal_server.models', function (require) { +"use strict"; +var models = require('point_of_sale.models'); +var devices = require('pos_payment_terminal_server.devices'); + +var _super_posmodel = models.PosModel.prototype; + +models.PosModel = models.PosModel.extend({ + initialize: function(session, attributes) { + var self = this; + _super_posmodel.initialize.call(this, session, attributes); + this.terminal_server = new devices.ProxyTerminalDevice(this); + }, + after_load_server_data: function(){ + self = this; + var done = _super_posmodel.after_load_server_data.call(this); + if(this.config.iface_payment_terminal_server){ + return this.connect_to_terminal_server(); + } + return done; + }, + connect_to_terminal_server: function(){ + var self = this; + var done = new $.Deferred(); + this.terminal_server.autoconnect({ + force_ip: self.config.iface_payment_terminal_server || undefined, + progress: function(prog){ + self.chrome.loading_progress(prog); + }, + }).always(function(){ + done.resolve(); + }); + return done; + }, +}); + + +}); + diff --git a/pos_payment_terminal_server/static/src/js/pos_payment_terminal.js b/pos_payment_terminal_server/static/src/js/pos_payment_terminal.js new file mode 100755 index 00000000..018de9f6 --- /dev/null +++ b/pos_payment_terminal_server/static/src/js/pos_payment_terminal.js @@ -0,0 +1,27 @@ +/* + Copyright 2019 ACSONE SA/NV + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + This is intended to manage the Start Transaction +*/ + +odoo.define('pos_payment_terminal_server.pos_payment_terminal', function (require) { + "use strict"; + + var screens = require('point_of_sale.screens'); + var devices = require('point_of_sale.devices'); + + screens.PaymentScreenWidget.include({ + render_paymentlines : function(){ + this._super.apply(this, arguments); + if (this.pos.config.iface_payment_terminal_server){ + var self = this; + this.$('.paymentlines-container').unbind('click').on('click', '.payment-terminal-transaction-start', function(event){ + self.pos.get_order().in_transaction = true; + self.order_changes(); + self.pos.terminal_server.payment_terminal_transaction_start($(this).data('cid'), self.pos.currency.name, self.pos.currency.decimals); + }); + } + } + }); +}); diff --git a/pos_payment_terminal_server/static/src/xml/pos_payment_terminal.xml b/pos_payment_terminal_server/static/src/xml/pos_payment_terminal.xml new file mode 100644 index 00000000..f9eff257 --- /dev/null +++ b/pos_payment_terminal_server/static/src/xml/pos_payment_terminal.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
diff --git a/pos_payment_terminal_server/views/pos_config.xml b/pos_payment_terminal_server/views/pos_config.xml new file mode 100644 index 00000000..f559baa5 --- /dev/null +++ b/pos_payment_terminal_server/views/pos_config.xml @@ -0,0 +1,23 @@ + + + + + + + pos.config.form (in pos_payment_multi_terminal) + pos.config + + + + + + + + + + + diff --git a/pos_payment_terminal_server/views/pos_payment_multi_terminal_template.xml b/pos_payment_terminal_server/views/pos_payment_multi_terminal_template.xml new file mode 100644 index 00000000..57c77d0a --- /dev/null +++ b/pos_payment_terminal_server/views/pos_payment_multi_terminal_template.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/setup/pos_payment_terminal_server/odoo_addons/__init__.py b/setup/pos_payment_terminal_server/odoo_addons/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/setup/pos_payment_terminal_server/odoo_addons/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/pos_payment_terminal_server/odoo_addons/pos_payment_terminal_server b/setup/pos_payment_terminal_server/odoo_addons/pos_payment_terminal_server new file mode 120000 index 00000000..c4e66210 --- /dev/null +++ b/setup/pos_payment_terminal_server/odoo_addons/pos_payment_terminal_server @@ -0,0 +1 @@ +../../../pos_payment_terminal_server \ No newline at end of file diff --git a/setup/pos_payment_terminal_server/setup.py b/setup/pos_payment_terminal_server/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/pos_payment_terminal_server/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)