diff --git a/addons/barcodes/static/src/js/barcode_events.js b/addons/barcodes/static/src/js/barcode_events.js index 5fcd68ac680..b07cf7bd19b 100644 --- a/addons/barcodes/static/src/js/barcode_events.js +++ b/addons/barcodes/static/src/js/barcode_events.js @@ -1,6 +1,7 @@ odoo.define('barcodes.BarcodeEvents', function(require) { "use strict"; +var config = require('web.config'); var core = require('web.core'); var mixins = require('web.mixins'); var session = require('web.session'); @@ -46,14 +47,7 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, { $(_.bind(this.start, this, false)); // Mobile device detection - var isMobile = navigator.userAgent.match(/Android/i) || - navigator.userAgent.match(/webOS/i) || - navigator.userAgent.match(/iPhone/i) || - navigator.userAgent.match(/iPad/i) || - navigator.userAgent.match(/iPod/i) || - navigator.userAgent.match(/BlackBerry/i) || - navigator.userAgent.match(/Windows Phone/i); - this.isChromeMobile = isMobile && navigator.userAgent.match(/Chrome/i); + this.isChromeMobile = config.device.isMobileDevice && navigator.userAgent.match(/Chrome/i); // Creates an input who will receive the barcode scanner value. this.$barcodeInput = $('', { diff --git a/addons/web/static/src/js/services/config.js b/addons/web/static/src/js/services/config.js index 8412c1319a8..91c3f1c764c 100644 --- a/addons/web/static/src/js/services/config.js +++ b/addons/web/static/src/js/services/config.js @@ -34,6 +34,20 @@ var config = { * @type Boolean */ isMobile: null, + /** + * Mobile device detection using userAgent. + * This flag doesn't depend on the size/resolution of the screen. + * It targets mobile devices which suggests that there is a virtual keyboard. + * + * @return {boolean} + */ + isMobileDevice: navigator.userAgent.match(/Android/i) || + navigator.userAgent.match(/webOS/i) || + navigator.userAgent.match(/iPhone/i) || + navigator.userAgent.match(/iPad/i) || + navigator.userAgent.match(/iPod/i) || + navigator.userAgent.match(/BlackBerry/i) || + navigator.userAgent.match(/Windows Phone/i), /** * Mapping between the numbers 0,1,2,3,4,5,6 and some descriptions */ diff --git a/addons/web/static/src/js/views/control_panel/control_panel_renderer.js b/addons/web/static/src/js/views/control_panel/control_panel_renderer.js index bdde2827e96..12d120b53ab 100644 --- a/addons/web/static/src/js/views/control_panel/control_panel_renderer.js +++ b/addons/web/static/src/js/views/control_panel/control_panel_renderer.js @@ -185,7 +185,7 @@ var ControlPanelRenderer = Renderer.extend({ * @private */ _focusSearchInput: function () { - if (this.withSearchBar && !config.device.isMobile) { + if (this.withSearchBar && !config.device.isMobileDevice) { // in mobile mode, we would rather not focus manually the // input, because it opens up the integrated keyboard, which is // not what you expect when you just selected a filter. diff --git a/addons/web/tests/test_js.py b/addons/web/tests/test_js.py index 71e96c8b3b8..2547a82d978 100644 --- a/addons/web/tests/test_js.py +++ b/addons/web/tests/test_js.py @@ -22,7 +22,7 @@ class WebSuite(odoo.tests.HttpCase): def _check_only_call(self, suite): # As we currently aren't in a request context, we can't render `web.layout`. # redefinied it as a minimal proxy template. - self.env.ref('web.layout').write({'arch_db': ''}) + self.env.ref('web.layout').write({'arch_db': ''}) for asset in self.env['ir.qweb']._get_asset_content(suite, options={})[0]: filename = asset['filename'] diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index 6de09a8379b..56a57751e03 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -417,7 +417,6 @@ - <link type="image/x-icon" rel="shortcut icon" t-att-href="x_icon or '/web/static/src/img/favicon.ico'"/>