user123
user123

Reputation: 577

Can not override "name" attribute on menu view in Odoo 11?

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?

Upvotes: 8

Views: 1579

Answers (3)

user123
user123

Reputation: 577

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.

Upvotes: 8

ChesuCR
ChesuCR

Reputation: 9670

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.

Upvotes: 5

sfx
sfx

Reputation: 1841

This will work

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

And do not forget to add hr in dependency

Upvotes: 2

Related Questions