From db682bfe74fcbc1059c34d0e60a69935b3b17407 Mon Sep 17 00:00:00 2001 From: Rohan Patel Date: Fri, 10 Jun 2016 12:15:46 +0530 Subject: [PATCH] [MIG] l10n_multilang : Migrated to new API. --- addons/l10n_multilang/__openerp__.py | 6 +- addons/l10n_multilang/models/account.py | 75 ++++++++----------- .../l10n_multilang/models/l10n_multilang.py | 12 +-- 3 files changed, 41 insertions(+), 52 deletions(-) diff --git a/addons/l10n_multilang/__openerp__.py b/addons/l10n_multilang/__openerp__.py index dc21161f1ea..523f86074d0 100644 --- a/addons/l10n_multilang/__openerp__.py +++ b/addons/l10n_multilang/__openerp__.py @@ -12,9 +12,5 @@ - Copy translations for COA, Tax, Tax Code and Fiscal Position from templates to target objects. """, - 'depends' : ['account'], - 'data': [], - 'demo': [], - 'installable': True, - 'auto_install': False, + 'depends': ['account'], } diff --git a/addons/l10n_multilang/models/account.py b/addons/l10n_multilang/models/account.py index b34c3c28c58..5b8a5e2745a 100644 --- a/addons/l10n_multilang/models/account.py +++ b/addons/l10n_multilang/models/account.py @@ -2,73 +2,64 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp.osv import fields, osv -from openerp.tools.translate import _ - +from odoo import fields, models #in this file, we mostly add the tag translate=True on existing fields that we now want to be translated -class account_account_template(osv.osv): + +class AccountAccountTemplate(models.Model): _inherit = 'account.account.template' - _columns = { - 'name': fields.char('Name', required=True, select=True, translate=True), - } -class account_account(osv.osv): + name = fields.Char(required=True, index=True, translate=True) + + +class AccountAccount(models.Model): _inherit = 'account.account' - _columns = { - 'name': fields.char('Name', required=True, select=True, translate=True), - } -class account_tax(osv.osv): + name = fields.Char(required=True, index=True, translate=True) + + +class AccountTax(models.Model): _inherit = 'account.tax' - _columns = { - 'name': fields.char('Tax Name', required=True, select=True, translate=True), - } + + name = fields.Char(string='Tax Name', required=True, index=True, translate=True) -class account_tax_template(osv.osv): +class AccountTaxTemplate(models.Model): _inherit = 'account.tax.template' - _columns = { - 'name': fields.char('Tax Name', required=True, select=True, translate=True), - } + + name = fields.Char(string='Tax Name', required=True, index=True, translate=True) -class account_chart_template(osv.osv): +class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' - _columns={ - 'name': fields.char('Name', required=True, translate=True), - 'spoken_languages': fields.char('Spoken Languages', help="State here the languages for which the translations of templates could be loaded at the time of installation of this localization module and copied in the final object when generating them from templates. You must provide the language codes separated by ';'"), - } _order = 'name' + name = fields.Char(required=True, translate=True) + spoken_languages = fields.Char(string='Spoken Languages', help="State here the languages for which the translations of templates could be loaded at the time of installation of this localization module and copied in the final object when generating them from templates. You must provide the language codes separated by ';'") -class account_fiscal_position(osv.osv): + +class AccountFiscalPosition(models.Model): _inherit = 'account.fiscal.position' - _columns = { - 'name': fields.char('Fiscal Position', required=True, translate=True), - 'note': fields.text('Notes', translate=True), - } + + name = fields.Char(string='Fiscal Position', required=True, translate=True) + note = fields.Text(string='Notes', translate=True) -class account_fiscal_position_template(osv.osv): +class AccountFiscalPositionTemplate(models.Model): _inherit = 'account.fiscal.position.template' - _columns = { - 'name': fields.char('Fiscal Position Template', required=True, translate=True), - 'note': fields.text('Notes', translate=True), - } + + name = fields.Char(string='Fiscal Position Template', required=True, translate=True) + note = fields.Text(string='Notes', translate=True) -class account_journal(osv.osv): +class AccountJournal(models.Model): _inherit = 'account.journal' - _columns = { - 'name': fields.char('Journal Name', required=True, translate=True), - } + + name = fields.Char(string='Journal Name', required=True, translate=True) -class account_analytic_account(osv.osv): +class AccountAnalyticAccount(models.Model): _inherit = 'account.analytic.account' - _columns = { - 'name': fields.char('Account Name', required=True, translate=True), - } + name = fields.Char(string='Account Name', required=True, translate=True) diff --git a/addons/l10n_multilang/models/l10n_multilang.py b/addons/l10n_multilang/models/l10n_multilang.py index fd2900dcbb8..8fccc62757a 100644 --- a/addons/l10n_multilang/models/l10n_multilang.py +++ b/addons/l10n_multilang/models/l10n_multilang.py @@ -1,10 +1,13 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import api, models, SUPERUSER_ID import logging + +from odoo import api, models + _logger = logging.getLogger(__name__) + class AccountChartTemplate(models.Model): _inherit = 'account.chart.template' @@ -38,7 +41,7 @@ class AccountChartTemplate(models.Model): 'value': value[element.id], }) else: - _logger.info('Language: %s. Translation from template: there is no translation available for %s!' %(lang, element.name)) + _logger.info('Language: %s. Translation from template: there is no translation available for %s!' % (lang, element.name)) counter += 1 return True @@ -85,16 +88,15 @@ class AccountChartTemplate(models.Model): return self.process_translations(langs, field, in_ids, out_ids) -class base_language_install(models.TransientModel): +class BaseLanguageInstall(models.TransientModel): """ Install Language""" - _inherit = "base.language.install" @api.multi def lang_install(self): self.ensure_one() already_installed = self.env['res.lang'].search_count([('code', '=', self.lang)]) - res = super(base_language_install, self).lang_install() + res = super(BaseLanguageInstall, self).lang_install() if already_installed: # update of translations instead of new installation # skip to avoid duplicating the translations