update_translations.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Script para actualizar traducciones y quitar 'Enterprise' de los nombres de módulos
  5. Ejecutar: python3 scripts/update_translations.py
  6. """
  7. import sys
  8. import os
  9. # Agregar ruta de Odoo
  10. sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../odoo'))
  11. import odoo
  12. from odoo import api, SUPERUSER_ID
  13. def update_translations():
  14. """Actualizar traducciones para quitar Enterprise"""
  15. # Configurar Odoo
  16. odoo.tools.config.parse_config(['-c', '../../../odoo.conf', '-d', 'm22_techconsulting_dev'])
  17. with odoo.api.Environment.manage():
  18. env = api.Environment(odoo.registry('m22_techconsulting_dev'), SUPERUSER_ID, {})
  19. try:
  20. Translation = env['ir.translation']
  21. # Buscar traducciones problemáticas
  22. translations = Translation.search([
  23. ('name', '=', 'helpdesk.affected.module,name'),
  24. ('lang', '=', 'es_MX'),
  25. ])
  26. print(f"🔍 Encontradas {len(translations)} traducciones para helpdesk.affected.module")
  27. # Filtrar las que contienen Enterprise
  28. problematic = [t for t in translations if 'Enterprise' in t.value or 'enterprise' in t.value.lower()]
  29. if not problematic:
  30. print("✅ No hay traducciones con 'Enterprise'")
  31. return
  32. print(f"🔄 Actualizando {len(problematic)} traducciones...")
  33. updates = {
  34. 'Web de Enterprise': 'Web',
  35. 'Web Enterprise': 'Web',
  36. 'Contabilidad Analítica Enterprise': 'Contabilidad Analítica',
  37. 'Analytic Accounting Enterprise': 'Contabilidad Analítica',
  38. 'Facturación (Enterprise)': 'Facturación',
  39. 'Facturación Enterprise': 'Facturación',
  40. 'Invoicing (Enterprise)': 'Facturación',
  41. }
  42. updated_count = 0
  43. for trans in problematic:
  44. old_value = trans.value
  45. new_value = updates.get(old_value)
  46. if not new_value:
  47. # Limpieza genérica
  48. new_value = old_value.replace('Enterprise', '').replace('enterprise', '')
  49. new_value = new_value.replace(' de ', ' ').replace(' (', '').replace(')', '')
  50. new_value = ' '.join(new_value.split()).strip()
  51. if old_value != new_value:
  52. trans.write({'value': new_value})
  53. updated_count += 1
  54. print(f"✅ '{old_value}' → '{new_value}'")
  55. env.cr.commit()
  56. print(f"\n✅ {updated_count} traducciones actualizadas exitosamente")
  57. except Exception as e:
  58. print(f"❌ Error: {e}")
  59. import traceback
  60. traceback.print_exc()
  61. env.cr.rollback()
  62. if __name__ == '__main__':
  63. update_translations()