Skip to Content

Contributors

Robust renaming in code

Hi,

I have a question that frequently arrises due to customer requests and I
never found a really nice solution for, despite this seams to be so
obvious need for customization.

How do I rename stuff (e.g. Entry from ir.ui.menu) defined in other
modules from within my customized module.

I know the various places in the UI, but I’m looking for a robust way to
define this in code.

It tried to just rename the entry in XML like so:

```
    
        Verkaufsprojekte
    
```

This is working, but the result doesn’t show up, because in the german
translation the original translated term is still used.

The changed value however doesn't appear in my modules .pot files on
export. So it doesn’t seam to be easily possible to change the
translated terms from my module.

One solution I came up with is to explicitly change the term in
ir_translation using XML, but this is a bit cumbersome.

```
    
        
        
    
```

How did you handle this?

Is there any other easy and robust, code based option for globally
renaming terms (e.g. menu entries) from within a customization module?

Thanks. Regards, Peter

by Pete Hahn - 11:30 - 31 Aug 2020

Follow-Ups

  • Re: Robust renaming in code
    Thanks, the i18n_extra folder was the thing I didn’t knew off.
    
    
    
    Am 31.08.20 um 11:41 schrieb Pedro M. Baeza (Tecnativa):
    
    > I "forbid" (not real forbidding, but persuasion) to do this in my customers, as the maintenance cost for such a whim doesn't worth it IMO. They adapt to current nomenclature easily when you involve serious (but real) costs about that.
    
    … I know, but … well … you know ;-)
    
    
    
    

    by Pete Hahn - 12:16 - 31 Aug 2020
  • Re: Robust renaming in code
    I "forbid" (not real forbidding, but persuasion) to do this in my customers, as the maintenance cost for such a whim doesn't worth it IMO. They adapt to current nomenclature easily when you involve serious (but real) costs about that.

    Anyway, if you still want do it, it depends on what to rename:

    - Fields: override `string` attribute of the field.
    - Menus: XML with the original XML-ID, but for translations, you need to add a i18n_extra folder.
    - Hardcoded string in reports: XML inheritance, replacing contents (which is also very bad for compatibility, but reduced if using a lower priority - 9999 or so-).

    Regards.

    by Pedro M. Baeza - 11:41 - 31 Aug 2020