[IMP] web: force desktop mode on mobile

Before this commit, some views appeared broken on mobile.
We don't consider this as a bug because Odoo is not supposed
to be responsive in Community edition. This feature is only
available on Enterprise.

This commit aims at clarifying this situation by clearly moving
the base requirements to support browsers' responsive to the
Enterprise edition and stating that the Community edition only
targets desktop.

It's important to note that, for technical reasons, some
responsive-related JS/CSS code may still be present in the
Community codebase but they are not meant to provide any
explicit or implicit support for responsive/mobile devices.

Technically speaking, this commit removes the viewport meta tag.
This change will then force the "desktop-like" rendering even on
small screens for the Community edition and will keep the current
behavior (scaling/zooming on small screens) for the Enterprise edition.

By doing this we do not let the users think that something is broken
and must be fixed.

So,
in Community edition, desktop is always displayed;
In Enterprise edition, Responsive Web Design is available.

We also had to adapt a test to be able to apply XPath adding
viewport meta tag in enterprise.

Task ID: 2090202

closes odoo/odoo#38768

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
This commit is contained in:
Odoo's Mergebot
2019-10-21 10:54:02 +02:00
committed by GitHub
5 changed files with 18 additions and 11 deletions
@@ -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 = $('<input/>', {
@@ -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
*/
@@ -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.
+1 -1
View File
@@ -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': '<t t-name="web.layout"><t t-raw="head"/></t>'})
self.env.ref('web.layout').write({'arch_db': '<t t-name="web.layout"><head><meta charset="utf-8"/><t t-raw="head"/></head></t>'})
for asset in self.env['ir.qweb']._get_asset_content(suite, options={})[0]:
filename = asset['filename']
-1
View File
@@ -417,7 +417,6 @@
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<title t-esc="title or 'Odoo'"/>
<link type="image/x-icon" rel="shortcut icon" t-att-href="x_icon or '/web/static/src/img/favicon.ico'"/>