8

I'm new to Odoo. I would like to change the top most menu name (with no action) from Employee to My new string.

<record id="hr.menu_hr_root" model="ir.ui.menu">
    <field name="name">My new string</field>
    <field name="sequence">92</field>
</record>

I'm sure that id is correct because sequence attribute is changed as expected. The problem is the name being unchanged anyway. The menu I want to modify is from default hr module. The only solution I have for now is to delete the record and recreate it with the new values. I tried to update on my own other menu views and they work as I expected, but the case from default hr module which is translated into my language (Vietnamese). Could anyone tell me some ideas about this?

user123
  • 577
  • 5
  • 23
  • 2
    Did you check if text showing is not the name of the action, and check if it's a translation problem – Charif DZ Jan 27 '19 at 14:29
  • Thanks you EasyOdoo, I think it's a translation problem too. As mentioned above, any menu that I created doesn't have the problem, just default module's menus are translated to my language (Vietnamese) in .po files, but I dont know how to deal with the problem (I'm new to Odoo). Could you tell me some suggestions? Thanks in advanced. – user123 Jan 27 '19 at 15:52
  • 1
    Action name is displayed at the top of the form not in the menu, so it shouldn't be a problem with action. If the problem is with translations, go to `settings->Translations->Generate Missing Terms`, then again got to `Settings->Translations->Translated Terms` and do the translation. Finally if you need the po file easiest way is to go to `Settings->Translations->export Translation` and get the PO file then copy the term into your PO file. – PMN Jan 27 '19 at 19:53
  • The display name I want to change is at the top navigation, it's a menu (top most menu with no action), not at the top of a form view. Thanks for your suggestion, may be I would like a programmatic way that I can change the values in .xml file to be same to other settings I made. – user123 Jan 28 '19 at 02:59

3 Answers3

8

I known the problem and resolved by myself. The problem is that any translable strings always is overrided upon translation. The code in my question works in the default language (English). After translation (on installing or setting preferences), the new "name" field doesn't work anymore (other fields are still work).

There are 2 solutions possible:

1) As I said in question, delete the record by id then redeclare the record (copy the code in the original module into the new one). The problem with the solution is the unnecessary duplication code.

2) Export a .po file (translator file) of the module and modify it as intended. Then insert the file into module’s subfolder i18n with the same path and name as the original module. Finally, run the odoo server with --i18n-overwrite flag to override the same file in the original module.

user123
  • 577
  • 5
  • 23
5

Try updating the name with the menuitem shortcut:

<menuitem id="hr.menu_hr_root"
          name="My new string"
          sequence="92" />

Try with the string attribute as well

<menuitem id="hr.menu_hr_root"
          string="My new string"
          sequence="92" />

A menuitem points to an action and it takes the name from there, so you may have to override the action name (as some users already commented in your question). Just an original example with the action + menu item:

<record model="ir.actions.act_window" id="account_analytic_distribution_action">
    <field name="name">Analytic distributions</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">account.analytic.distribution</field>
    <field name="view_type">form</field>
    <field name="view_mode">tree,form</field>
    <field name="search_view_id" ref="account_analytic_distribution_search"/>
</record>

<menuitem parent="account.menu_analytic_accounting"
          id="menu_account_analytic_distribution"
          action="account_analytic_distribution_action"
          groups="analytic.group_analytic_accounting" />

And to modify the action name:

<record model="ir.actions.act_window" id="account.account_analytic_distribution_action">
    <field name="name">New name</field>
</record>

If the problem is just happening with the translations check if this answer is useful. Updating base module used to work in older versions.

As a workaround you can go to the translated items and update the values directly.

ChesuCR
  • 9,352
  • 5
  • 51
  • 114
2

This will work

<menuitem id="hr.menu_hr_root" name="your new string" sequence="92" />

And do not forget to add hr in dependency

sfx
  • 1,793
  • 17
  • 24