From 2fe11b18b50d68fe9c1a1ed44ecee4eccb903bce Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Tue, 8 Sep 2015 15:00:21 +0200 Subject: [PATCH] Revert "[IMP] base: use currency position from language" NB : Not reviewed by apr and qdp This reverts commit 58f16b7060824d840984a66331066439370f41e8. --- openerp/addons/base/res/res_currency.py | 15 +-------------- openerp/addons/base/res/res_lang.py | 3 --- openerp/addons/base/res/res_lang_view.xml | 1 - openerp/addons/test_converter/tests/test_html.py | 7 ++----- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index 64df7525ec1..b5256847e5c 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -53,19 +53,6 @@ class res_currency(osv.osv): res[currency.id] = 0 return res - def _compute_position(self, cr, uid, ids, name, arg, context=None): - res = {} - if not context: - context = {} - - lang = self.pool['res.lang'] - lang_id = lang._lang_get(cr, uid, context.get('lang')) - position = lang.read(cr, uid, lang_id, ['position'], context=context)['position'] - for currency in self.browse(cr, uid, ids, context=context): - res[currency.id] = position - - return res - _name = "res.currency" _description = "Currency" _columns = { @@ -78,7 +65,7 @@ class res_currency(osv.osv): 'rounding': fields.float('Rounding Factor', digits=(12,6)), 'decimal_places': fields.function(_decimal_places, string='Decimal Places', type='integer'), 'active': fields.boolean('Active'), - 'position': fields.function(_compute_position, type='char', string="Currency Symbol Position"), + 'position': fields.selection([('after','After Amount'),('before','Before Amount')], 'Symbol Position', help="Determines where the currency symbol should be placed after or before the amount.") } _defaults = { 'active': 1, diff --git a/openerp/addons/base/res/res_lang.py b/openerp/addons/base/res/res_lang.py index 1b0ce53b305..92a8e0e8652 100644 --- a/openerp/addons/base/res/res_lang.py +++ b/openerp/addons/base/res/res_lang.py @@ -94,7 +94,6 @@ class lang(osv.osv): 'time_format' : fix_datetime_format(locale.nl_langinfo(locale.T_FMT)), 'decimal_point' : fix_xa0(str(locale.localeconv()['decimal_point'])), 'thousands_sep' : fix_xa0(str(locale.localeconv()['thousands_sep'])), - 'position': 'before' if locale.nl_langinfo(locale.CRNCYSTR)[0] == '-' else 'after' } lang_id = False try: @@ -138,7 +137,6 @@ class lang(osv.osv): 'grouping':fields.char('Separator Format', required=True,help="The Separator Format should be like [,n] where 0 < n :starting from Unit digit.-1 will end the separation. e.g. [3,2,-1] will represent 106500 to be 1,06,500;[1,2,-1] will represent it to be 106,50,0;[3] will represent it as 106,500. Provided ',' as the thousand separator in each case."), 'decimal_point':fields.char('Decimal Separator', required=True), 'thousands_sep':fields.char('Thousands Separator'), - 'position': fields.selection([('after','After Amount'),('before','Before Amount')], 'Currency Symbol Position', help="Determines where the currency symbol should be placed after or before the amount.") } _defaults = { 'active': 1, @@ -149,7 +147,6 @@ class lang(osv.osv): 'grouping': '[]', 'decimal_point': '.', 'thousands_sep': ',', - 'position': 'after' } _sql_constraints = [ ('name_uniq', 'unique (name)', 'The name of the language must be unique !'), diff --git a/openerp/addons/base/res/res_lang_view.xml b/openerp/addons/base/res/res_lang_view.xml index 33ee0fee987..4c2a203ac13 100644 --- a/openerp/addons/base/res/res_lang_view.xml +++ b/openerp/addons/base/res/res_lang_view.xml @@ -38,7 +38,6 @@ - diff --git a/openerp/addons/test_converter/tests/test_html.py b/openerp/addons/test_converter/tests/test_html.py index 52554f6e122..2f50602c115 100644 --- a/openerp/addons/test_converter/tests/test_html.py +++ b/openerp/addons/test_converter/tests/test_html.py @@ -95,7 +95,6 @@ class TestCurrencyExport(TestExport): super(TestCurrencyExport, self).setUp() self.Currency = self.registry('res.currency') self.base = self.create(self.Currency, name="Source", symbol=u'source') - self.lang_en = self.registry['ir.model.data'].xmlid_to_object(self.cr, self.uid, 'base.lang_en') def create(self, model, context=None, **values): return model.browse( @@ -120,7 +119,6 @@ class TestCurrencyExport(TestExport): return converted def test_currency_post(self): - self.lang_en.write({'position': 'after'}) currency = self.create(self.Currency, name="Test", symbol=u"test") obj = self.create(self.Model, value=0.12) @@ -138,8 +136,8 @@ class TestCurrencyExport(TestExport): ).encode('utf-8'),) def test_currency_pre(self): - self.lang_en.write({'position': 'before'}) - currency = self.create(self.Currency, name="Test", symbol=u"test") + currency = self.create( + self.Currency, name="Test", symbol=u"test", position='before') obj = self.create(self.Model, value=0.12) converted = self.convert(obj, dest=currency) @@ -159,7 +157,6 @@ class TestCurrencyExport(TestExport): def test_currency_precision(self): """ Precision should be the currency's, not the float field's """ - self.lang_en.write({'position': 'after'}) currency = self.create(self.Currency, name="Test", symbol=u"test",) obj = self.create(self.Model, value=0.1234567)