From d9826546b821528604f954468ed827dc3a5a4038 Mon Sep 17 00:00:00 2001 From: nicomacr Date: Tue, 5 Sep 2017 10:21:39 -0300 Subject: [PATCH] [10.0] DEL account_no_translation --- account_no_translation/README.rst | 22 ----- account_no_translation/__init__.py | 7 -- account_no_translation/__manifest__.py | 39 --------- account_no_translation/hooks.py | 83 ------------------- account_no_translation/i18n/ca.po | 44 ---------- account_no_translation/i18n/es.po | 29 ------- account_no_translation/i18n/gl.po | 44 ---------- .../migrations/9.0.1.1.0/post-migration.py | 50 ----------- account_no_translation/models/__init__.py | 6 -- account_no_translation/models/account.py | 34 -------- 10 files changed, 358 deletions(-) delete mode 100644 account_no_translation/README.rst delete mode 100755 account_no_translation/__init__.py delete mode 100644 account_no_translation/__manifest__.py delete mode 100644 account_no_translation/hooks.py delete mode 100644 account_no_translation/i18n/ca.po delete mode 100644 account_no_translation/i18n/es.po delete mode 100644 account_no_translation/i18n/gl.po delete mode 100644 account_no_translation/migrations/9.0.1.1.0/post-migration.py delete mode 100644 account_no_translation/models/__init__.py delete mode 100644 account_no_translation/models/account.py diff --git a/account_no_translation/README.rst b/account_no_translation/README.rst deleted file mode 100644 index 98efa44b2..000000000 --- a/account_no_translation/README.rst +++ /dev/null @@ -1,22 +0,0 @@ -Account no Translation -====================== - -This module sets the translatable fields of the accounting objects (name, -descriptions) to non-translatable fields. - -This change is usefull for companies that work with only one language. - -IMPORTANT: this module will uninstall "l10n_multilang" if installed (and any module that depend on it). It will also sync the values of translations of first installed language (different from en_US) as source values. - -Models and fields: - -* Account Type: Name -* Account Tax Code: Name -* Account Payment Term: Name and Note -* Account Tax: Name - -And if you also uninstall l10n_multilang, this fields will also be no translatable: -* Account Journal: Name -* Account Analytic Account: Name -* Account Analytic Journal: Name -* Account Account: Name diff --git a/account_no_translation/__init__.py b/account_no_translation/__init__.py deleted file mode 100755 index 97e33a979..000000000 --- a/account_no_translation/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in module root -# directory -############################################################################## -from . import models -from .hooks import post_init_hook diff --git a/account_no_translation/__manifest__.py b/account_no_translation/__manifest__.py deleted file mode 100644 index 4320c05c4..000000000 --- a/account_no_translation/__manifest__.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar) -# All Rights Reserved. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -{ - 'name': 'Account no Translation', - 'version': '9.0.1.1.0', - 'category': 'Accounting', - 'author': 'ADHOC SA', - 'website': 'www.adhoc.com.ar', - 'license': 'AGPL-3', - 'depends': [ - 'account', - ], - 'data': [ - ], - 'demo': [ - ], - 'test': [ - ], - 'installable': False, - 'post_init_hook': 'post_init_hook', -} diff --git a/account_no_translation/hooks.py b/account_no_translation/hooks.py deleted file mode 100644 index ac9f7982b..000000000 --- a/account_no_translation/hooks.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in module root -# directory -############################################################################## -# from openerp import models, fields, api -# import cStringIO -# from openerp import tools -from openerp import SUPERUSER_ID -import logging -_logger = logging.getLogger(__name__) - - -def post_init_hook(cr, registry): - """ - Desinstalamos l10n_multilang si está instalado, no debería ser muy - peligroso porque solo modulos de plan de cuentas dependeria de el - """ - sync_translations(cr, registry) - - module_pool = registry['ir.module.module'] - module_ids = module_pool.search( - cr, SUPERUSER_ID, - [('name', '=', 'l10n_multilang'), ('state', '=', 'installed')], {}) - if not module_ids: - return True - _logger.info('Uninstalling module "l10n_multilang"') - module_pool.button_uninstall( - cr, SUPERUSER_ID, module_ids, {}) - _logger.info('Module "l10n_multilang" sucessfully uninstalled') - return True - - -def sync_translations(cr, registry): - lang_read = registry['res.lang'].search_read( - cr, SUPERUSER_ID, [ - '&', ('active', '=', True), ('translatable', '=', True), - ('code', '!=', 'en_US')], ['code'], limit=1) - if not lang_read: - # no need to sync translations, only en_us language - return True - lang_code = lang_read[0]['code'] - models_fields = [ - ('account.payment.term', 'name'), - ('account.payment.term', 'note'), - ('account.tax', 'name'), - ('account.tax', 'description'), - ('account.tax.group', 'name'), - ] - for model_name, field_name in models_fields: - sync_field( - cr, registry, SUPERUSER_ID, lang_code, model_name, field_name) - - -def sync_field(cr, registry, uid, lang_code, model_name, field_name): - _logger.info('Syncking translations for model %s, field %s' % ( - model_name, field_name)) - # pool = RegistryManager.get(cr.dbname) - translations = registry['ir.translation'].search_read( - cr, SUPERUSER_ID, [ - ('name', '=', '%s,%s' % (model_name, field_name)), - ('type', '=', 'model'), - ('lang', '=', 'es_AR')], - ['res_id', 'value']) - for translation in translations: - table = model_name.replace('.', '_') - value = translation['value'] - # algunas veces la trad es vacias - if not value: - continue - res_id = translation['res_id'] - _logger.info('Syncking on res_id %s, value %s, field_name %s' % ( - res_id, value, field_name)) - # just in case some constraint block de renaiming - # try: - # no nos anduvo, arrojamos el error y listo - sql_str = "UPDATE %s SET %s=%%s WHERE id=%%s" % (table, field_name) - cr.execute(sql_str, (value, res_id)) - # except Exception, e: - # _logger.warning( - # 'Could not update translation on table %s for res_id %s, ' - # 'field %s, with value %s. This is what we get %s' % ( - # table, res_id, field_name, value, e)) diff --git a/account_no_translation/i18n/ca.po b/account_no_translation/i18n/ca.po deleted file mode 100644 index 6a3dacf13..000000000 --- a/account_no_translation/i18n/ca.po +++ /dev/null @@ -1,44 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_no_translation -# -# Translators: -# Juan José Scarafía , 2016 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-07-27 00:54+0000\n" -"PO-Revision-Date: 2016-07-27 00:54+0000\n" -"Last-Translator: Juan José Scarafía , 2016\n" -"Language-Team: Catalan (https://www.transifex.com/adhoc/teams/46451/ca/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: ca\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_account -msgid "Account" -msgstr "Compte" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_account_type -msgid "Account Type" -msgstr "" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_payment_term -msgid "Payment Term" -msgstr "" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_tax -msgid "Tax" -msgstr "" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_tax_code -msgid "Tax Code" -msgstr "" diff --git a/account_no_translation/i18n/es.po b/account_no_translation/i18n/es.po deleted file mode 100644 index f3ce4b135..000000000 --- a/account_no_translation/i18n/es.po +++ /dev/null @@ -1,29 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_no_translation -# -# Translators: -# Juan José Scarafía , 2016 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-13 20:47+0000\n" -"PO-Revision-Date: 2016-11-13 20:47+0000\n" -"Last-Translator: Juan José Scarafía , 2016\n" -"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/46451/es/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: es\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_payment_term -msgid "Payment Term" -msgstr "Término de Pago" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_tax -msgid "Tax" -msgstr "Impuesto" diff --git a/account_no_translation/i18n/gl.po b/account_no_translation/i18n/gl.po deleted file mode 100644 index 79a909a1f..000000000 --- a/account_no_translation/i18n/gl.po +++ /dev/null @@ -1,44 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_no_translation -# -# Translators: -# Juan José Scarafía , 2016 -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-07-27 00:54+0000\n" -"PO-Revision-Date: 2016-07-27 00:54+0000\n" -"Last-Translator: Juan José Scarafía , 2016\n" -"Language-Team: Galician (https://www.transifex.com/adhoc/teams/46451/gl/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: gl\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_account -msgid "Account" -msgstr "Conta" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_account_type -msgid "Account Type" -msgstr "" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_payment_term -msgid "Payment Term" -msgstr "" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_tax -msgid "Tax" -msgstr "" - -#. module: account_no_translation -#: model:ir.model,name:account_no_translation.model_account_tax_code -msgid "Tax Code" -msgstr "" diff --git a/account_no_translation/migrations/9.0.1.1.0/post-migration.py b/account_no_translation/migrations/9.0.1.1.0/post-migration.py deleted file mode 100644 index 4c32017b7..000000000 --- a/account_no_translation/migrations/9.0.1.1.0/post-migration.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -from openupgradelib import openupgrade -import logging -_logger = logging.getLogger(__name__) - - -@openupgrade.migrate(use_env=True) -def migrate(env, version): - sync_translations(env) - - -def sync_translations(env): - lang_read = env['res.lang'].search_read( - ['&', ('active', '=', True), ('translatable', '=', True), - ('code', '!=', 'en_US')], ['code'], limit=1) - if not lang_read: - # no need to sync translations, only en_us language - return True - lang_code = lang_read[0]['code'] - models_fields = [ - ('account.tax', 'description'), - ] - for model_name, field_name in models_fields: - sync_field(env, lang_code, model_name, field_name) - - -def sync_field(env, lang_code, model_name, field_name): - _logger.info('Syncking translations for model %s, field %s' % ( - model_name, field_name)) - # pool = RegistryManager.get(cr.dbname) - translations = env['ir.translation'].search_read( - [ - ('name', '=', '%s,%s' % (model_name, field_name)), - ('type', '=', 'model'), - ('lang', '=', 'es_AR')], - ['res_id', 'value']) - for translation in translations: - table = model_name.replace('.', '_') - value = translation['value'] - res_id = translation['res_id'] - # just in case some constraint block de renaiming - # try: - # no nos anduvo, arrojamos el error y listo - env.cr.execute( - "UPDATE %s SET %s='%s' WHERE id=%s" % ( - table, - field_name, - value, - res_id - )) diff --git a/account_no_translation/models/__init__.py b/account_no_translation/models/__init__.py deleted file mode 100644 index 47a56fe46..000000000 --- a/account_no_translation/models/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in module root -# directory -############################################################################## -from . import account diff --git a/account_no_translation/models/account.py b/account_no_translation/models/account.py deleted file mode 100644 index d0cf6b48b..000000000 --- a/account_no_translation/models/account.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in module root -# directory -############################################################################## -from openerp import models, fields - - -# la idea es no modificarlos por lo cual no es tan relevante que no sea -# traducible -# class AccountAccountType(models.Model): -# _inherit = 'account.account.type' - -# name = fields.Char(translate=False) - - -class AccountTaxCode(models.Model): - _inherit = 'account.tax.group' - - name = fields.Char(translate=False) - - -class AccountTax(models.Model): - _inherit = 'account.tax' - - name = fields.Char(translate=False) - description = fields.Char(translate=False) - - -class AccountPaymentTerm(models.Model): - _inherit = 'account.payment.term' - - name = fields.Char(translate=False) - note = fields.Char(translate=False)