summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-05-14 14:37:08 +0200
committerChristophe Simonis <chs@odoo.com>2018-05-14 14:37:08 +0200
commitbd2de7ae7884deb8fbde0354d617c0776384ad4a (patch)
tree9dc22107364554a9c590a4e346e8d9e25a0df3cd
parentf88a05d18e43c0d6dc36bc50df0db4507865e9e1 (diff)
parentd818b516c14947235152f14827c996c5bb01655d (diff)
[MERGE] forward port branch saas-15 up to d818b516c14
-rw-r--r--addons/http_routing/geoipresolver.py8
-rw-r--r--addons/point_of_sale/models/pos_order.py2
-rw-r--r--addons/point_of_sale/views/report_saledetails.xml3
-rw-r--r--addons/web_editor/static/src/js/editor/summernote.js8
-rw-r--r--addons/web_editor/static/src/js/editor/transcoder.js34
-rw-r--r--odoo/addons/base/tests/test_mail.py4
-rw-r--r--odoo/addons/base/tests/test_mail_examples.py2
-rw-r--r--odoo/tools/mail.py2
8 files changed, 47 insertions, 16 deletions
diff --git a/addons/http_routing/geoipresolver.py b/addons/http_routing/geoipresolver.py
index 1f9b0e22724..e95b9318eb2 100644
--- a/addons/http_routing/geoipresolver.py
+++ b/addons/http_routing/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/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py
index c7bc8266cbb..00360ff1384 100644
--- a/addons/point_of_sale/models/pos_order.py
+++ b/addons/point_of_sale/models/pos_order.py
@@ -175,7 +175,7 @@ class PosOrder(models.Model):
'comment': self.note or '',
# considering partner's sale pricelist's currency
'currency_id': self.pricelist_id.currency_id.id,
- 'user_id': self.env.uid,
+ 'user_id': self.user_id.id,
}
@api.model
diff --git a/addons/point_of_sale/views/report_saledetails.xml b/addons/point_of_sale/views/report_saledetails.xml
index dea4d1a9e62..89ebc22648c 100644
--- a/addons/point_of_sale/views/report_saledetails.xml
+++ b/addons/point_of_sale/views/report_saledetails.xml
@@ -22,7 +22,8 @@
</tr></thead>
<tbody>
<tr t-foreach='products' t-as='line'>
- <td><t t-esc="line['product_name']" /></td>
+ <t t-set="internal_reference" t-value="line['code'] and '[%s] ' % line['code'] or ''" />
+ <td><t t-esc="internal_reference" /><t t-esc="line['product_name']" /></td>
<td>
<t t-esc="line['quantity']" />
<t t-if='line["uom"] != "Unit(s)"'>
diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js
index dc97da37365..256d20f9d5f 100644
--- a/addons/web_editor/static/src/js/editor/summernote.js
+++ b/addons/web_editor/static/src/js/editor/summernote.js
@@ -1975,7 +1975,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/editor/transcoder.js b/addons/web_editor/static/src/js/editor/transcoder.js
index d207efdd54b..9ca19f01ac3 100644
--- a/addons/web_editor/static/src/js/editor/transcoder.js
+++ b/addons/web_editor/static/src/js/editor/transcoder.js
@@ -227,6 +227,26 @@ function imgToFont($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
+ */
+function applyOverDescendants(node, func) {
+ node = node.firstChild;
+ while (node) {
+ if (node.nodeType === 1) {
+ func(node);
+ applyOverDescendants(node, func);
+ }
+ node = node.nextSibling;
+ }
+}
+
/**
* Converts css style to inline style (leave the classes on elements but forces
* the style they give as inline style).
@@ -237,9 +257,9 @@ function classToStyle($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))) {
@@ -269,7 +289,7 @@ function classToStyle($editable) {
$target.after($hack);
$target.appendTo($hack.find('td'));
// the space add a line when it's a table but it's invisible when it's a link
- var node = $hack[0].previousSibling;
+ node = $hack[0].previousSibling;
if (node && node.nodeType === Node.TEXT_NODE && !node.textContent.match(/\S/)) {
$(node).remove();
}
@@ -297,9 +317,9 @@ function styleToClass($editable) {
var $c = $('<span/>').appendTo(document.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/odoo/addons/base/tests/test_mail.py b/odoo/addons/base/tests/test_mail.py
index 84cf892ea30..57850047fc6 100644
--- a/odoo/addons/base/tests/test_mail.py
+++ b/odoo/addons/base/tests/test_mail.py
@@ -114,7 +114,7 @@ class TestSanitizer(unittest.TestCase):
test_data = [
(
'<span style="position: fixed; top: 0px; left: 50px; width: 40%; height: 50%; background-color: red;">Coin coin </span>',
- ['background-color: red', 'Coin coin'],
+ ['background-color:red', 'Coin coin'],
['position', 'top', 'left']
), (
"""<div style='before: "Email Address; coincoin cheval: lapin";
@@ -122,7 +122,7 @@ class TestSanitizer(unittest.TestCase):
this; means: anything ?#รนยต"
; some-property: 2px; top: 3'>youplaboum</div>""",
- ['font-size: 30px', 'youplaboum'],
+ ['font-size:30px', 'youplaboum'],
['some-property', 'top', 'cheval']
), (
'<span style="width">Coincoin</span>',
diff --git a/odoo/addons/base/tests/test_mail_examples.py b/odoo/addons/base/tests/test_mail_examples.py
index 4f3b5b48300..032d321ff06 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 = u"""
</div>
"""
REMOVE_CLASS_IN = [
- u'<div style="font-size: 12pt; font-family: \'Times New Roman\'; color: #000000">',
+ u'<div style="font-size:12pt; font-family:\'Times New Roman\'; color:#000000">',
u'An error occured in a modal and I will send you back the html to try opening one on your end']
REMOVE_CLASS_OUT = [
u'<div class="modal-backdrop in">',
diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py
index 97a3e427a94..5c02b3aa3e3 100644
--- a/odoo/tools/mail.py
+++ b/odoo/tools/mail.py
@@ -155,7 +155,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.items())
+ el.attrib['style'] = '; '.join('%s:%s' % (key, val) for (key, val) in valid_styles.items())
else:
del el.attrib['style']