- |
+
+ |
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js
index 964ececa06b..1c5feb7a7d4 100644
--- a/addons/web_editor/static/src/js/backend.js
+++ b/addons/web_editor/static/src/js/backend.js
@@ -146,7 +146,7 @@ var FieldTextHtmlSimple = widget.extend({
this.$content.html(this.text_to_html(value));
if (this.get("effective_readonly")) {
this.resize();
- } else {
+ } else if (this.options['style-inline']) {
transcoder.style_to_class(this.$content);
}
if (this.$content.is(document.activeElement)) {
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js
index 435c5d7fa78..bae44f1998c 100644
--- a/addons/web_editor/static/src/js/summernote.js
+++ b/addons/web_editor/static/src/js/summernote.js
@@ -2003,7 +2003,13 @@ eventHandler.modules.toolbar.button.updateRecentColor = function (elBtn, sEvent,
};
$(document).on('click keyup', function () {
- var $popover = $((range.create()||{}).sc).closest('[contenteditable]');
+ var current_range = {};
+ try {
+ current_range = range.create() || {};
+ } catch (e) {
+ // if range is on Restricted element ignore error
+ }
+ var $popover = $(current_range.sc).closest('[contenteditable]');
var popover_history = ($popover.data()||{}).NoteHistory;
if(!popover_history || popover_history == history) return;
var editor = $popover.parent('.note-editor');
diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js
index a5cf20575d4..aff3b3210f6 100644
--- a/addons/web_editor/static/src/js/transcoder.js
+++ b/addons/web_editor/static/src/js/transcoder.js
@@ -182,14 +182,34 @@ var img_to_font = function ($editable) {
});
};
+/*
+ * Utility function to apply function over descendants elements
+ *
+ * This is needed until the following issue of jQuery is solved:
+ * https://github.com./jquery/sizzle/issues/403
+ *
+ * @param {Element} node The root Element node
+ * @param {Function} func The function applied over descendants
+ */
+var applyOverDescendants = function (node, func) {
+ node = node.firstChild;
+ while (node) {
+ if (node.nodeType === 1) {
+ func(node);
+ applyOverDescendants(node, func);
+ }
+ node = node.nextSibling;
+ }
+};
+
// convert class into inline style to send by mail
var class_to_style = function ($editable) {
if (!rulesCache.length) {
getMatchedCSSRules($editable[0]);
}
- $editable.find('*').each(function () {
- var $target = $(this);
- var css = getMatchedCSSRules(this);
+ applyOverDescendants($editable[0], function (node) {
+ var $target = $(node);
+ var css = getMatchedCSSRules(node);
var style = $target.attr("style") || "";
_.each(css, function (v,k) {
if (!(new RegExp('(^|;)\s*' + k).test(style))) {
@@ -209,9 +229,9 @@ var style_to_class = function ($editable) {
var $c = $('').appendTo("body");
- $editable.find('*').each(function () {
- var $target = $(this);
- var css = getMatchedCSSRules(this);
+ applyOverDescendants($editable[0], function (node) {
+ var $target = $(node);
+ var css = getMatchedCSSRules(node);
var style = "";
_.each(css, function (v,k) {
if (!(new RegExp('(^|;)\s*' + k).test(style))) {
diff --git a/addons/website/geoipresolver.py b/addons/website/geoipresolver.py
index 1f9b0e22724..e95b9318eb2 100644
--- a/addons/website/geoipresolver.py
+++ b/addons/website/geoipresolver.py
@@ -47,10 +47,14 @@ class GeoIPResolver(object):
r = self._db.city(ip)
except (ValueError, geoip2.errors.AddressNotFoundError):
return {}
+ # Compatibility with Legacy database.
+ # Some ips cannot be located to a specific country. Legacy DB used to locate them in
+ # continent instead of country. Do the same to not change behavior of existing code.
+ country = r.country if r.country.geoname_id else r.continent
return {
'city': r.city.name,
- 'country_code': r.country.iso_code,
- 'country_name': r.country.name,
+ 'country_code': country.iso_code,
+ 'country_name': country.name,
'region': r.subdivisions[0].iso_code if r.subdivisions else None,
'time_zone': r.location.time_zone,
}
diff --git a/odoo/addons/base/tests/test_mail.py b/odoo/addons/base/tests/test_mail.py
index 795d6824886..b94ebf57183 100644
--- a/odoo/addons/base/tests/test_mail.py
+++ b/odoo/addons/base/tests/test_mail.py
@@ -115,7 +115,7 @@ class TestSanitizer(unittest.TestCase):
test_data = [
(
'Coin coin ',
- ['background-color: red', 'Coin coin'],
+ ['background-color:red', 'Coin coin'],
['position', 'top', 'left']
), (
""" youplaboum """,
- ['font-size: 30px', 'youplaboum'],
+ ['font-size:30px', 'youplaboum'],
['some-property', 'top', 'cheval']
), (
'Coincoin',
diff --git a/odoo/addons/base/tests/test_mail_examples.py b/odoo/addons/base/tests/test_mail_examples.py
index a83e668d940..fcd83524fc0 100644
--- a/odoo/addons/base/tests/test_mail_examples.py
+++ b/odoo/addons/base/tests/test_mail_examples.py
@@ -510,7 +510,7 @@ REMOVE_CLASS = """
"""
REMOVE_CLASS_IN = [
- '',
+ ' ',
'An error occured in a modal and I will send you back the html to try opening one on your end']
REMOVE_CLASS_OUT = [
' ',
diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py
index d994494e727..9071f472f88 100644
--- a/odoo/tools/mail.py
+++ b/odoo/tools/mail.py
@@ -154,7 +154,7 @@ class _Cleaner(clean.Cleaner):
if style[0].lower() in self._style_whitelist:
valid_styles[style[0].lower()] = style[1]
if valid_styles:
- el.attrib['style'] = '; '.join('%s: %s' % (key, val) for (key, val) in valid_styles.iteritems())
+ el.attrib['style'] = '; '.join('%s:%s' % (key, val) for (key, val) in valid_styles.iteritems())
else:
del el.attrib['style']
|