[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
This commit is contained in:
@@ -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}'
|
||||
|
||||
@@ -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):
|
||||
'<span data-oe-model="{obj._model._name}" data-oe-id="{obj.id}" '
|
||||
'data-oe-field="value" data-oe-type="monetary" '
|
||||
'data-oe-expression="obj.value">'
|
||||
'<span class="oe_currency_value">0.12</span>'
|
||||
u'<span class="oe_currency_value">\u20110.12</span>'
|
||||
u'\N{NO-BREAK SPACE}{symbol}</span>'.format(
|
||||
obj=obj,
|
||||
symbol=currency.symbol.encode('utf-8')
|
||||
|
||||
Reference in New Issue
Block a user