diff --git a/account.py b/account.py index 03c809146f..db9f802c1b 100644 --- a/account.py +++ b/account.py @@ -12,7 +12,6 @@ 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 from trytond.backend import TableHandler __all__ = ['TypeTemplate', 'Type', 'OpenType', 'AccountTemplate', 'Account', @@ -114,6 +113,7 @@ class TypeTemplate(ModelSQL, ModelView): pool = Pool() Type = pool.get('account.account.type') Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2type is None: template2type = {} @@ -125,7 +125,7 @@ class TypeTemplate(ModelSQL, ModelView): new_type = Type.create(vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self._fields.iteritems(): if getattr(field, 'translate', False): @@ -274,7 +274,9 @@ class Type(ModelSQL, ModelView): value, used to convert template id into type. The dictionary is filled with new types ''' - Lang = Pool().get('ir.lang') + pool = Pool() + Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2type is None: template2type = {} @@ -284,7 +286,7 @@ class Type(ModelSQL, ModelView): if vals: self.write([self], vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self.template._fields.iteritems(): if getattr(field, 'translate', False): @@ -431,6 +433,7 @@ class AccountTemplate(ModelSQL, ModelView): pool = Pool() Account = pool.get('account.account') Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2account is None: template2account = {} @@ -447,7 +450,7 @@ class AccountTemplate(ModelSQL, ModelView): new_account = Account.create(vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self._fields.iteritems(): if getattr(field, 'translate', False): @@ -883,7 +886,9 @@ class Account(ModelSQL, ModelView): template2type is a dictionary with type template id as key and type id as value, used to convert type template id into type. ''' - Lang = Pool().get('ir.lang') + pool = Pool() + Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2account is None: template2account = {} @@ -901,7 +906,7 @@ class Account(ModelSQL, ModelView): if vals: self.write([self], vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self.template._fields.iteritems(): if getattr(field, 'translate', False): @@ -1650,8 +1655,9 @@ class CreateChart(Wizard): TaxRuleTemplate = pool.get('account.tax.rule.template') TaxRuleLineTemplate = \ pool.get('account.tax.rule.line.template') + Config = pool.get('ir.configuration') - with Transaction().set_context(language=CONFIG['language']): + with Transaction().set_context(language=Config.get_language()): account_template = self.account.account_template # Create account types diff --git a/tax.py b/tax.py index 150cb7782a..ceb1e8102e 100644 --- a/tax.py +++ b/tax.py @@ -7,7 +7,6 @@ from trytond.backend import TableHandler from trytond.pyson import Eval, If, Bool, PYSONEncoder from trytond.transaction import Transaction from trytond.pool import Pool, PoolMeta -from trytond.config import CONFIG __all__ = ['TaxGroup', 'TaxCodeTemplate', 'TaxCode', 'OpenChartTaxCodeStart', 'OpenChartTaxCode', @@ -85,6 +84,7 @@ class TaxCodeTemplate(ModelSQL, ModelView): pool = Pool() TaxCode = pool.get('account.tax.code') Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2tax_code is None: template2tax_code = {} @@ -96,7 +96,7 @@ class TaxCodeTemplate(ModelSQL, ModelView): new_tax_code = TaxCode.create(vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self._fields.iteritems(): if getattr(field, 'translate', False): @@ -238,7 +238,9 @@ class TaxCode(ModelSQL, ModelView): tax code id as value, used to convert template id into tax code. The dictionary is filled with new tax codes ''' - Lang = Pool().get('ir.lang') + pool = Pool() + Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2tax_code is None: template2tax_code = {} @@ -248,7 +250,7 @@ class TaxCode(ModelSQL, ModelView): if vals: self.write([self], vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self.template._fields.iteritems(): if getattr(field, 'translate', False): @@ -446,6 +448,7 @@ class TaxTemplate(ModelSQL, ModelView): pool = Pool() Tax = pool.get('account.tax') Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2tax is None: template2tax = {} @@ -487,7 +490,7 @@ class TaxTemplate(ModelSQL, ModelView): new_tax = Tax.create(vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self._fields.iteritems(): if getattr(field, 'translate', False): @@ -747,7 +750,9 @@ class Tax(ModelSQL, ModelView): value, used to convert template id into tax. The dictionary is filled with new taxes. ''' - Lang = Pool().get('ir.lang') + pool = Pool() + Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2tax is None: template2tax = {} @@ -806,7 +811,7 @@ class Tax(ModelSQL, ModelView): if vals: self.write([self], vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self.template._fields.iteritems(): if getattr(field, 'translate', False): @@ -888,6 +893,7 @@ class TaxRuleTemplate(ModelSQL, ModelView): pool = Pool() Rule = pool.get('account.tax.rule') Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2rule is None: template2rule = {} @@ -897,7 +903,7 @@ class TaxRuleTemplate(ModelSQL, ModelView): vals['company'] = company_id new_rule = Rule.create(vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self._fields.iteritems(): if getattr(field, 'translate', False): @@ -954,7 +960,9 @@ class TaxRule(ModelSQL, ModelView): rule id as value, used to convert template id into tax rule. The dictionary is filled with new tax rules. ''' - Lang = Pool().get('ir.lang') + pool = Pool() + Lang = pool.get('ir.lang') + Config = pool.get('ir.configuration') if template2rule is None: template2rule = {} @@ -964,7 +972,7 @@ class TaxRule(ModelSQL, ModelView): if vals: self.write([self], vals) - prev_lang = self._context.get('language') or CONFIG['language'] + prev_lang = self._context.get('language') or Config.get_language() prev_data = {} for field_name, field in self.template._fields.iteritems(): if getattr(field, 'translate', False):