From 3bf0effd1492a8c2e568ed70e4d21ba7d732bfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 27 Jan 2012 21:13:00 +0100 Subject: [PATCH] Add default database language code review200001 --- account.py | 20 +++++++++----------- move.py | 5 +++-- tax.py | 13 +++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/account.py b/account.py index 28dcb5b31a..b8868f9109 100644 --- a/account.py +++ b/account.py @@ -10,6 +10,7 @@ from trytond.tools import reduce_ids from trytond.pyson import Eval, PYSONEncoder, Date from trytond.transaction import Transaction from trytond.pool import Pool +from trytond.config import CONFIG class TypeTemplate(ModelSQL, ModelView): @@ -114,7 +115,7 @@ class TypeTemplate(ModelSQL, ModelView): new_id = type_obj.create(vals) - prev_lang = template._context.get('language') or 'en_US' + prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -279,7 +280,7 @@ class Type(ModelSQL, ModelView): if vals: self.write(type.id, vals) - prev_lang = type._context.get('language') or 'en_US' + prev_lang = type._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in type.template._columns.iteritems(): if getattr(field, 'translate', False): @@ -440,7 +441,7 @@ class AccountTemplate(ModelSQL, ModelView): new_id = account_obj.create(vals) - prev_lang = template._context.get('language') or 'en_US' + prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -914,7 +915,7 @@ class Account(ModelSQL, ModelView): if vals: self.write(account.id, vals) - prev_lang = account._context.get('language') or 'en_US' + prev_lang = account._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in account.template._columns.iteritems(): if getattr(field, 'translate', False): @@ -1488,13 +1489,10 @@ class OpenBalanceSheet(Wizard): lang_obj = pool.get('ir.lang') company = session.start.company - for code in [Transaction().language, 'en_US']: - lang_ids = lang_obj.search([ - ('code', '=', code), + lang_id, = lang_obj.search([ + ('code', '=', Transaction().language), ]) - if lang_ids: - break - lang = lang_obj.browse(lang_ids[0]) + lang = lang_obj.browse(lang_id) date = lang_obj.strftime(session.start.date, lang.code, lang.date) @@ -1686,7 +1684,7 @@ class CreateChart(Wizard): tax_rule_line_template_obj = \ pool.get('account.tax.rule.line.template') - with Transaction().set_context(language='en_US'): + with Transaction().set_context(language=CONFIG['language']): account_template = session.account.account_template # Create account types diff --git a/move.py b/move.py index 7ca1a17066..baca9b2cf8 100644 --- a/move.py +++ b/move.py @@ -16,6 +16,7 @@ from trytond.backend import TableHandler, FIELDS from trytond.pyson import Eval, PYSONEncoder from trytond.transaction import Transaction from trytond.pool import Pool +from trytond.config import CONFIG _MOVE_STATES = { 'readonly': Eval('state') == 'posted', @@ -1250,10 +1251,10 @@ class Line(ModelSQL, ModelView): account = line.account amount = currency_obj.round(account.currency, amount) period_id = period_obj.find(account.company.id, date=date) - lang_code = 'en_US' + lang_code = CONFIG['language'] if account.company.lang: lang_code = account.company.lang.code - writeoff = translation_obj._get_source( + writeoff = translation_obj.get_source( 'account.move.reconcile_lines.writeoff', 'view', lang_code, 'Write-Off') or 'Write-Off' move_id = move_obj.create({ diff --git a/tax.py b/tax.py index 372f2675b8..81fb04cd67 100644 --- a/tax.py +++ b/tax.py @@ -8,6 +8,7 @@ from trytond.pyson import Eval, If, Bool, PYSONEncoder from trytond.transaction import Transaction from trytond.cache import Cache from trytond.pool import Pool +from trytond.config import CONFIG class Group(ModelSQL, ModelView): @@ -104,7 +105,7 @@ class CodeTemplate(ModelSQL, ModelView): new_id = tax_code_obj.create(vals) - prev_lang = template._context.get('language') or 'en_US' + prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -274,7 +275,7 @@ class Code(ModelSQL, ModelView): if vals: self.write(code.id, vals) - prev_lang = code._context.get('language') or 'en_US' + prev_lang = code._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in code.template._columns.iteritems(): if getattr(field, 'translate', False): @@ -510,7 +511,7 @@ class TaxTemplate(ModelSQL, ModelView): new_id = tax_obj.create(vals) - prev_lang = template._context.get('language') or 'en_US' + prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -858,7 +859,7 @@ class Tax(ModelSQL, ModelView): if vals: self.write(tax.id, vals) - prev_lang = tax._context.get('language') or 'en_US' + prev_lang = tax._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in tax.template._columns.iteritems(): if getattr(field, 'translate', False): @@ -975,7 +976,7 @@ class RuleTemplate(ModelSQL, ModelView): vals['company'] = company_id new_id = rule_obj.create(vals) - prev_lang = template._context.get('language') or 'en_US' + prev_lang = template._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in template._columns.iteritems(): if getattr(field, 'translate', False): @@ -1065,7 +1066,7 @@ class Rule(ModelSQL, ModelView): if vals: self.write(rule.id, vals) - prev_lang = rule._context.get('language') or 'en_US' + prev_lang = rule._context.get('language') or CONFIG['language'] prev_data = {} for field_name, field in rule.template._columns.iteritems(): if getattr(field, 'translate', False):