From 07df48592fb56e7d240697a2100c6fa107982fec Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Mon, 29 Aug 2022 14:24:27 +0000 Subject: [PATCH] [IMP] hw_posbox_homepage: restart buttons added Before, the user had to manually unplug and replug the IoT Box to reboot it. Also, it was required to connect to the IoT box to restart Odoo service. This improvement adds the 'Restart Odoo' and 'Reboot IoT box' buttons on the box's form view to IoT app. They allow the user to reboot the IoT box and restart Odoo service on it remotely from the IoT app in Odoo. task-2476576 closes odoo/odoo#101045 X-original-commit: 662b41293315ae934502c683939d9820e4ca451a Related: odoo/enterprise#31747 Signed-off-by: Quentin Lejeune (qle) --- addons/hw_posbox_homepage/controllers/main.py | 13 ++++ addons/hw_posbox_homepage/views/homepage.html | 78 +++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/addons/hw_posbox_homepage/controllers/main.py b/addons/hw_posbox_homepage/controllers/main.py index b428ecc8caa..f5571ac5e1a 100644 --- a/addons/hw_posbox_homepage/controllers/main.py +++ b/addons/hw_posbox_homepage/controllers/main.py @@ -356,3 +356,16 @@ class IoTboxHomepage(Home): self.clean_partition() _logger.error('A error encountered : %s ' % e) return Response(str(e), status=500) + + @http.route('/iot_restart_odoo_or_reboot', type='json', auth='none', cors='*', csrf=False) + def iot_restart_odoo_or_reboot(self, action): + """ Reboots the IoT Box / restarts Odoo on it depending on chosen 'action' argument""" + try: + if action == 'restart_odoo': + helpers.odoo_restart(3) + else: + subprocess.call(['sudo', 'reboot']) + return 'success' + except Exception as e: + _logger.error('An error encountered : %s ', e) + return str(e) diff --git a/addons/hw_posbox_homepage/views/homepage.html b/addons/hw_posbox_homepage/views/homepage.html index a2ae801df7f..d116b5cd4de 100644 --- a/addons/hw_posbox_homepage/views/homepage.html +++ b/addons/hw_posbox_homepage/views/homepage.html @@ -1,6 +1,25 @@ {% extends "layout.html" %} +{% from "loading.html" import loading_block_ui %} {% block head %}