From 173cfd8915576fbfadbfa29dd5bc1c8196b68f9c Mon Sep 17 00:00:00 2001 From: lejeune quentin Date: Wed, 4 Sep 2019 13:50:15 +0000 Subject: [PATCH] [FIX] hw_posbox_homepage: Fix to rename IoT Box We must be able to change the hostname of IoT Box even if we do not pass him a token. So we give a default value to 'url' and 'token' closes odoo/odoo#36428 Signed-off-by: Quentin Lejeune (qle) --- addons/hw_posbox_homepage/controllers/main.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/hw_posbox_homepage/controllers/main.py b/addons/hw_posbox_homepage/controllers/main.py index d5d6ebdbd95..8a5ca64be87 100644 --- a/addons/hw_posbox_homepage/controllers/main.py +++ b/addons/hw_posbox_homepage/controllers/main.py @@ -226,14 +226,18 @@ class IoTboxHomepage(web.Home): @http.route('/server_connect', type='http', auth='none', cors='*', csrf=False) def connect_to_server(self, token, iotname): - credential = token.split('|') - url = credential[0] - token = credential[1] - if len(credential) > 2: - # IoT Box send token with db_uuid and enterprise_code only since V13 - db_uuid = credential[2] - enterprise_code = credential[3] - helpers.add_credential(db_uuid, enterprise_code) + if token: + credential = token.split('|') + url = credential[0] + token = credential[1] + if len(credential) > 2: + # IoT Box send token with db_uuid and enterprise_code only since V13 + db_uuid = credential[2] + enterprise_code = credential[3] + helpers.add_credential(db_uuid, enterprise_code) + else: + url = helpers.get_odoo_server_url() + token = helpers.get_token() reboot = 'reboot' subprocess.check_call([get_resource_path('point_of_sale', 'tools/posbox/configuration/connect_to_server.sh'), url, iotname, token, reboot]) return 'http://' + helpers.get_ip() + ':8069'