| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Script para actualizar traducciones y quitar 'Enterprise' de los nombres de módulos
- Ejecutar: python3 scripts/update_translations.py
- """
- import sys
- import os
- # Agregar ruta de Odoo
- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../odoo'))
- import odoo
- from odoo import api, SUPERUSER_ID
- def update_translations():
- """Actualizar traducciones para quitar Enterprise"""
- # Configurar Odoo
- odoo.tools.config.parse_config(['-c', '../../../odoo.conf', '-d', 'm22_techconsulting_dev'])
-
- with odoo.api.Environment.manage():
- env = api.Environment(odoo.registry('m22_techconsulting_dev'), SUPERUSER_ID, {})
-
- try:
- Translation = env['ir.translation']
-
- # Buscar traducciones problemáticas
- translations = Translation.search([
- ('name', '=', 'helpdesk.affected.module,name'),
- ('lang', '=', 'es_MX'),
- ])
-
- print(f"🔍 Encontradas {len(translations)} traducciones para helpdesk.affected.module")
-
- # Filtrar las que contienen Enterprise
- problematic = [t for t in translations if 'Enterprise' in t.value or 'enterprise' in t.value.lower()]
-
- if not problematic:
- print("✅ No hay traducciones con 'Enterprise'")
- return
-
- print(f"🔄 Actualizando {len(problematic)} traducciones...")
-
- updates = {
- 'Web de Enterprise': 'Web',
- 'Web Enterprise': 'Web',
- 'Contabilidad Analítica Enterprise': 'Contabilidad Analítica',
- 'Analytic Accounting Enterprise': 'Contabilidad Analítica',
- 'Facturación (Enterprise)': 'Facturación',
- 'Facturación Enterprise': 'Facturación',
- 'Invoicing (Enterprise)': 'Facturación',
- }
-
- updated_count = 0
- for trans in problematic:
- old_value = trans.value
- new_value = updates.get(old_value)
-
- if not new_value:
- # Limpieza genérica
- new_value = old_value.replace('Enterprise', '').replace('enterprise', '')
- new_value = new_value.replace(' de ', ' ').replace(' (', '').replace(')', '')
- new_value = ' '.join(new_value.split()).strip()
-
- if old_value != new_value:
- trans.write({'value': new_value})
- updated_count += 1
- print(f"✅ '{old_value}' → '{new_value}'")
-
- env.cr.commit()
- print(f"\n✅ {updated_count} traducciones actualizadas exitosamente")
-
- except Exception as e:
- print(f"❌ Error: {e}")
- import traceback
- traceback.print_exc()
- env.cr.rollback()
- if __name__ == '__main__':
- update_translations()
|