[FIX] base: QWeb monetary format

- Set the currency precision to 0.05
- Print any QWeb report displaying amounts, e.g. the GL

The amounts are displayed with 1 digit precision instead of 2.

The formula used to compute the decimal places is actually wrong. The
correct one can be found in method `_decimal_places`. Anyway, we can use
directly the field.

opw-752283
This commit is contained in:
Nicolas Martinelli
2017-07-14 15:27:48 +02:00
parent 13a3e76a48
commit 6331cd1ff5
+1 -2
View File
@@ -1051,8 +1051,7 @@ class QwebWidgetMonetary(osv.AbstractModel):
def _format(self, inner, options, qwebcontext):
inner = self.pool['ir.qweb'].eval(inner, qwebcontext)
display = self.pool['ir.qweb'].eval_object(options['display_currency'], qwebcontext)
precision = int(round(math.log10(display.rounding)))
fmt = "%.{0}f".format(-precision if precision < 0 else 0)
fmt = "%.{0}f".format(display.decimal_places)
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