| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- # -*- coding: utf-8 -*-
- import logging
- from odoo import api, SUPERUSER_ID
- _logger = logging.getLogger(__name__)
- def migrate(cr, version):
- """Actualizar traducciones para quitar 'Enterprise' de los nombres de módulos"""
- env = api.Environment(cr, SUPERUSER_ID, {})
-
- # Actualizar traducciones en ir.translation
- Translation = env['ir.translation']
-
- # Buscar traducciones problemáticas
- translations = Translation.search([
- ('name', '=', 'helpdesk.affected.module,name'),
- ('lang', '=', 'es_MX'),
- ('value', 'ilike', 'Enterprise'),
- ])
-
- _logger.info(f"Encontradas {len(translations)} traducciones con 'Enterprise' para actualizar")
-
- 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 translations:
- 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
- _logger.info(f"Actualizado: '{old_value}' → '{new_value}'")
-
- cr.commit()
- _logger.info(f"✅ {updated_count} traducciones actualizadas exitosamente")
|