From f50ba68be72c8b63af87e8dcd0e726e5e3b77092 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 16 Mar 2017 17:42:39 +0100 Subject: [PATCH 1/4] [FIX] web_editor: handle margin:initial correctly The transcoder (which transforms stylesheet rules to inline style) did some compression of the padding and margin css properties to not always have margin-top + margin-right + margin-bottom + margin-left. This could cause an issue when the value of margin or padding contained an initial or inherit value because browsers (at least firefox and google chrome) doesn't allow it. Thus the preview could for example have bigger veritcal spaces arround `

` tag than what was seen when editing. With this fix instead of invalid: margin:initial initial initial initial we have: margin:initial And instead of invalid: margin:initial 5px 6px 7px we have: margin-top: initial; margin-right: 5px; margin-bottom: 6px; margin-left: 7px; opw-706535 --- addons/web_editor/static/src/js/transcoder.js | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js index d327252b63d..306369cddfa 100644 --- a/addons/web_editor/static/src/js/transcoder.js +++ b/addons/web_editor/static/src/js/transcoder.js @@ -99,20 +99,28 @@ var getMatchedCSSRules = function (a) { if (style.display === 'block') { delete style.display; } - if (style['margin-top']) { - style.margin = (style['margin-top'] || 0) + ' ' + (style['margin-right'] || 0) + ' ' + (style['margin-bottom'] || 0) + ' ' + (style['margin-left'] || 0); - delete style['margin-top']; - delete style['margin-right']; - delete style['margin-bottom']; - delete style['margin-left']; - } - if (style['padding-top']) { - style.padding = (style['padding-top'] || 0) + ' ' + (style['padding-right'] || 0) + ' ' + (style['padding-bottom'] || 0) + ' ' + (style['padding-left'] || 0); - delete style['padding-top']; - delete style['padding-right']; - delete style['padding-bottom']; - delete style['padding-left']; - } + + _.each(['margin', 'padding'], function(p) { + if (style[p+'-top'] || style[p+'-right'] || style[p+'-bottom'] || style[p+'-left']) { + if (style[p+'-top'] === style[p+'-right'] && style[p+'-top'] === style[p+'-bottom'] && style[p+'-top'] === style[p+'-left']) { + // keep => property: [top/right/bottom/left value]; + style[p] = style[p+'-top']; + } + else { + // keep => property: [top value] [right value] [bottom value] [left value]; + style[p] = (style[p+'-top'] || 0) + ' ' + (style[p+'-right'] || 0) + ' ' + (style[p+'-bottom'] || 0) + ' ' + (style[p+'-left'] || 0); + if (style[p].indexOf('inherit') !== -1 || style[p].indexOf('initial') !== -1) { + // keep => property-top: [top value]; property-right: [right value]; property-bottom: [bottom value]; property-left: [left value]; + delete style[p]; + return; + } + } + delete style[p+'-top']; + delete style[p+'-right']; + delete style[p+'-bottom']; + delete style[p+'-left']; + } + }); return a.className ? cache[a.tagName + "." +a.className] = style : style; }; From fb05d8845d92b1ca9013307664fa6d52be64aa3d Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 16 Mar 2017 16:07:29 +0100 Subject: [PATCH 2/4] [FIX] web_calendar: events not appearing in arabic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fullcalendar expect as `start` and `end` property of an event object: > When specifying Event Objects for events or eventSources, you may > specify a string in IETF format (ex: "Wed, 18 Oct 2009 13:00:00 EST"), > a string in ISO8601 format (ex: "2009-11-05T13:15:30Z") or a UNIX > timestamp. (as seen in https://fullcalendar.io/docs1/event_data/Event_Object/) Before this commit we could for example in arabic provide an invalid date string "٢٠١٧-٠٣-١٦ ١٦:٠٠:٠٦" instead of "2017-03-16 16:00:06". This commit solves this by always providing fullcalendar an ISO8601 date string. opw-705752 --- addons/web_calendar/static/src/js/web_calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index b98f155ad9a..89d125c48af 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -639,8 +639,8 @@ var CalendarView = View.extend({ date_stop = m_start.toDate(); } var r = { - 'start': moment(date_start).format('YYYY-MM-DD HH:mm:ss'), - 'end': moment(date_stop).format('YYYY-MM-DD HH:mm:ss'), + 'start': moment(date_start).toISOString(), + 'end': moment(date_stop).toISOString(), 'title': the_title, 'allDay': (this.fields[this.date_start].type == 'date' || (this.all_day && evt[this.all_day]) || false), 'id': evt.id, From 508a002e699f6e0935b43798637a6603823d9524 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 17 Mar 2017 07:39:39 +0100 Subject: [PATCH 3/4] [FIX] web_editor: glitch english several times When using the iframed editor with multilang selector (present if there is another lang installed than en_US) an "English" language was present before each translation language. opw-696891 --- addons/web_editor/static/src/xml/backend.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web_editor/static/src/xml/backend.xml b/addons/web_editor/static/src/xml/backend.xml index 957f38dac3c..c5b668cc01a 100644 --- a/addons/web_editor/static/src/xml/backend.xml +++ b/addons/web_editor/static/src/xml/backend.xml @@ -38,11 +38,11 @@ -webkit-border-radius: 3px; border-radius: 3px; background: white;"> + - From af64780a2d8df2ec5ec91bab4bc0cc0a7f2c050a Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 16 Mar 2017 15:46:38 +0100 Subject: [PATCH 4/4] [FIX] base: no-break hyphen - Create an invoice with two products - Each line has a long description (spread on 2 lines) - The second line has a negative value - Print the invoice (PDF) The amount spreads on two lines, split as: $ - 1,000.00 This is due to the wkhtmltopdf version with patched QT. Unfortunately, upgrading to the latest version 0.12.4 doesn't solve the problem. The solution is to replace the '-' by a non-breakable hyphen. opw-711002 --- openerp/addons/base/ir/ir_qweb.py | 8 ++++---- openerp/addons/test_converter/tests/test_html.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index 4d7e5a02061..ea996769f88 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -686,7 +686,7 @@ class IntegerConverter(osv.AbstractModel): context = {} lang_code = context.get('lang') or 'en_US' - return self.pool['res.lang'].format(cr, uid, [lang_code], '%d', value, grouping=True) + return self.pool['res.lang'].format(cr, uid, [lang_code], '%d', value, grouping=True).replace(r'-', u'\u2011') class FloatConverter(osv.AbstractModel): _name = 'ir.qweb.field.float' @@ -704,7 +704,7 @@ class FloatConverter(osv.AbstractModel): lang_code = context.get('lang') or 'en_US' lang = self.pool['res.lang'] - formatted = lang.format(cr, uid, [lang_code], fmt.format(precision=precision), value, grouping=True) + formatted = lang.format(cr, uid, [lang_code], fmt.format(precision=precision), value, grouping=True).replace(r'-', u'\u2011') # %f does not strip trailing zeroes. %g does but its precision causes # it to switch to scientific notation starting at a million *and* to @@ -889,7 +889,7 @@ class MonetaryConverter(osv.AbstractModel): lang = self.pool['res.lang'] formatted_amount = lang.format(cr, uid, [lang_code], fmt, Currency.round(cr, uid, display_currency, from_amount), - grouping=True, monetary=True).replace(r' ', u'\N{NO-BREAK SPACE}') + grouping=True, monetary=True).replace(r' ', u'\N{NO-BREAK SPACE}').replace(r'-', u'\u2011') pre = post = u'' if display_currency.position == 'before': @@ -1056,7 +1056,7 @@ class QwebWidgetMonetary(osv.AbstractModel): lang_code = qwebcontext.context.get('lang') or 'en_US' formatted_amount = self.pool['res.lang'].format( qwebcontext.cr, qwebcontext.uid, [lang_code], fmt, inner, grouping=True, monetary=True - ).replace(r' ', u'\N{NO-BREAK SPACE}') + ).replace(r' ', u'\N{NO-BREAK SPACE}').replace(r'-', u'\u2011') pre = post = u'' if display.position == 'before': pre = u'{symbol}\N{NO-BREAK SPACE}' diff --git a/openerp/addons/test_converter/tests/test_html.py b/openerp/addons/test_converter/tests/test_html.py index 2f50602c115..5810e24c288 100644 --- a/openerp/addons/test_converter/tests/test_html.py +++ b/openerp/addons/test_converter/tests/test_html.py @@ -67,8 +67,8 @@ class TestFloatExport(TestBasicExport): def test_float(self): converter = self.get_converter('float') - value = converter(42.0) - self.assertEqual(value, "42.0") + value = converter(-42.0) + self.assertEqual(value, u"\u201142.0") value = converter(42.0100) self.assertEqual(value, "42.01") @@ -120,7 +120,7 @@ class TestCurrencyExport(TestExport): def test_currency_post(self): currency = self.create(self.Currency, name="Test", symbol=u"test") - obj = self.create(self.Model, value=0.12) + obj = self.create(self.Model, value=-0.12) converted = self.convert(obj, dest=currency) @@ -129,7 +129,7 @@ class TestCurrencyExport(TestExport): '' - '0.12' + u'\u20110.12' u'\N{NO-BREAK SPACE}{symbol}'.format( obj=obj, symbol=currency.symbol.encode('utf-8')