diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py
index 0f829f7a982..2090233f20d 100644
--- a/openerp/addons/base/ir/ir_qweb.py
+++ b/openerp/addons/base/ir/ir_qweb.py
@@ -559,13 +559,8 @@ class ImageConverter(osv.AbstractModel):
return '
' % (Image.MIME[image.format], value)
class MonetaryConverter(osv.AbstractModel):
- """ ``monetary`` converter, has two mandatory options ``source_currency``
- and ``display_currency``. Both are evaluated in the qweb context, must
- yield a res.currency browse_record and are used to convert currency field
- value into a display value, and (using the display currency) format the
- currency symbol.
-
- The currency field is a (float) value.
+ """ ``monetary`` converter, has a mandatory option
+ ``display_currency``.
.. note:: the monetary converter internally adds the qweb context to its
options mapping, so that the context is available to callees.
@@ -582,12 +577,8 @@ class MonetaryConverter(osv.AbstractModel):
source_element, t_att, g_att, qweb_context)
def record_to_html(self, cr, uid, field_name, record, column, options):
- source = self.source_currency(cr, uid, options)
display = self.display_currency(cr, uid, options)
- value = self.pool['res.currency'].compute(
- cr, uid, source.id, display.id, record[field_name])
-
symbol_pre = symbol_post = space_pre = space_post = u''
if display.position == 'before':
space_pre = u' '
@@ -599,16 +590,12 @@ class MonetaryConverter(osv.AbstractModel):
return u'{symbol_pre}{space_pre}' \
u'{0}' \
u'{space_post}{symbol_post}'.format(
- value,
+ record[field_name],
space_pre=space_pre,
symbol_pre=symbol_pre,
space_post=space_post,
symbol_post=symbol_post,)
- def source_currency(self, cr, uid, options):
- return self.qweb_object().eval_object(
- options['source_currency'], options['_qweb_context'])
-
def display_currency(self, cr, uid, options):
return self.qweb_object().eval_object(
options['display_currency'], options['_qweb_context'])
diff --git a/openerp/tests/addons/test_converter/tests/test_html.py b/openerp/tests/addons/test_converter/tests/test_html.py
index 06e7ffce97a..f0c48df4a93 100644
--- a/openerp/tests/addons/test_converter/tests/test_html.py
+++ b/openerp/tests/addons/test_converter/tests/test_html.py
@@ -92,23 +92,17 @@ class TestCurrencyExport(TestExport):
converter = self.registry('ir.qweb.field.monetary')
options = {
'widget': 'monetary',
- 'source_currency': 'c1',
'display_currency': 'c2'
}
converted = converter.to_html(
self.cr, self.uid, 'value', obj, options,
doc.createElement('span'),
{'field': 'obj.value', 'field-options': json.dumps(options)},
- '', {'obj': obj, 'c1': self.base, 'c2': dest, })
+ '', {'obj': obj, 'c2': dest, })
return converted
- def create_rate(self, currency, rate=1.0):
- Rate = self.registry('res.currency.rate')
- self.create(Rate, name='1970-01-01', rate=rate, currency_id=currency.id)
-
def test_currency_post(self):
currency = self.create(self.Currency, name="Test", symbol=u"test")
- self.create_rate(currency)
obj = self.create(self.Model, value=0.12)
converted = self.convert(obj, dest=currency)
@@ -127,7 +121,6 @@ class TestCurrencyExport(TestExport):
def test_currency_pre(self):
currency = self.create(
self.Currency, name="Test", symbol=u"test", position='before')
- self.create_rate(currency)
obj = self.create(self.Model, value=0.12)
converted = self.convert(obj, dest=currency)
@@ -144,30 +137,10 @@ class TestCurrencyExport(TestExport):
symbol=currency.symbol.encode('utf-8')
),)
- def test_currency_rate_conversion(self):
- currency = self.create(
- self.Currency, name="Test", symbol=u"dest")
- self.create_rate(currency, rate=2.0)
- obj = self.create(self.Model, value=0.12)
-
- converted = self.convert(obj, dest=currency)
-
- self.assertEqual(
- converted,
- ''
- '0.24'
- ' {symbol}'.format(
- obj=obj,
- symbol=currency.symbol.encode('utf-8')
- ),)
-
def test_currency_precision(self):
""" Precision should be the currency's, not the float field's
"""
currency = self.create(self.Currency, name="Test", symbol=u"test",)
- self.create_rate(currency)
obj = self.create(self.Model, value=0.1234567)
converted = self.convert(obj, dest=currency)