[MERGE] forward port branch saas-14 up to 5274a62037

This commit is contained in:
Christophe Simonis
2018-05-14 12:28:37 +02:00
10 changed files with 48 additions and 16 deletions
+1 -1
View File
@@ -169,7 +169,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,
}
def _action_create_invoice_line(self, line=False, invoice_id=False):
@@ -272,6 +272,7 @@ exports.PosModel = Backbone.Model.extend({
// replace the current user with its updated version
if (user.id === self.user.id) {
self.user = user;
self.set_cashier(user);
}
}
self.users = pos_users;
@@ -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)"'>
+1 -1
View File
@@ -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)) {
@@ -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');
+26 -6
View File
@@ -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 = $('<span/>').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))) {
+6 -2
View File
@@ -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,
}
+2 -2
View File
@@ -115,7 +115,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";
@@ -123,7 +123,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>',
+1 -1
View File
@@ -510,7 +510,7 @@ REMOVE_CLASS = """
</div>
"""
REMOVE_CLASS_IN = [
'<div style="color: #000000; font-size: 12pt; font-family: \'Times New Roman\'">',
'<div style="color:#000000; font-size:12pt; font-family:\'Times New Roman\'">',
'An error occured in a modal and I will send you back the html to try opening one on your end']
REMOVE_CLASS_OUT = [
'<div class="modal-backdrop in">',
+1 -1
View File
@@ -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']