`device_name` and `scanner_name` were defined outside of the scope of the function where they were used in. We move them and try to simplify the logic a bit. closes odoo/odoo#56454 X-original-commit: e59e311578aa0b4539ef27580462a2c2e1dce970 Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com> Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>