From 1e1236776ed461528d11525ee71742758e423f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20M=C3=A9quignon?= Date: Wed, 28 Apr 2021 13:14:27 +0200 Subject: [PATCH] stock_measuring_device: Auto-refresh zipcube wiz when measurement is done --- .../static/src/js/measuring_wizard.js | 10 ++++------ stock_measuring_device/wizard/measuring_wizard.py | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/stock_measuring_device/static/src/js/measuring_wizard.js b/stock_measuring_device/static/src/js/measuring_wizard.js index 766e6ac7f..bd9fc40c4 100644 --- a/stock_measuring_device/static/src/js/measuring_wizard.js +++ b/stock_measuring_device/static/src/js/measuring_wizard.js @@ -28,21 +28,19 @@ odoo.define("stock_measuring_device.measuring_wizard", function(require) { var channel = notification[0]; var message = notification[1]; if (channel === "notify_measuring_wizard_screen") { - switch (message.action) { - case "refresh": - self.measuring_wizard_bus_action_refresh(message.params); - break; + if (message.action === "refresh") { + self.measuring_wizard_bus_action_refresh(message.params); } } }); }, measuring_wizard_bus_action_refresh: function(params) { var selectedIds = this.getSelectedIds(); - if (!selectedIds.length) { + if (!selectedIds.length || params.model !== this.modelName) { return; } var currentId = selectedIds[0]; - if (params.id === currentId && params.model === this.modelName) { + if (params.id === currentId) { this.reload(); } }, diff --git a/stock_measuring_device/wizard/measuring_wizard.py b/stock_measuring_device/wizard/measuring_wizard.py index addcd6e3c..2ee9bd709 100644 --- a/stock_measuring_device/wizard/measuring_wizard.py +++ b/stock_measuring_device/wizard/measuring_wizard.py @@ -167,6 +167,7 @@ class MeasuringWizard(models.TransientModel): def _send_notification_refresh(self): """Send a refresh notification on the wizard. + Other notifications can be implemented, they have to be added in static/src/js/measuring_wizard.js and the message must contain an "action" and "params".