How to Delete a Menu in OpenErp

Asked by John Chen

Hi

There is a Product Category menu in Sales Menu.
I would like to delete the Product Category. I already use CTRL + L in OpenErp Client to delete the product category. And i am going to replace the menu with another menu that i created already.

Is there any others way to delete the product category without using CTRL + L, i would like to do it with .py, .xml file to import it.
Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Web Client Edit question
Assignee:
No assignee Edit question
Solved by:
digitalsatori(Shine IT)
Solved:
Last query:
Last reply:
Revision history for this message
Quentin THEURET @Amaris (qtheuret) said :
#1

Le 22/06/2011 09:31, John Chen a écrit :
> New question #162301 on OpenERP Web Client:
> https://answers.launchpad.net/openobject-client-web/+question/162301
>
> Hi
>
> There is a Product Category menu in Sales Menu.
> I would like to delete the Product Category. I already use CTRL + L in
OpenErp Client to delete the product category. And i am going to replace
the menu with another menu that i created already.
>
> Is there any others way to delete the product category without using
CTRL + L, i would like to do it with .py, .xml file to import it.
> Thanks
>
Hello John,

If you would replace a menu by your own, the best way is to give the
same id of the replaced menu to the new menu (be careful to give the
menu id in this format : module.menu_id  for example to replace the
purchase root menu, give the id like this : base.menu_purchase_root)

If you would delete a menu, try this : <delete model='ir.ui.menu'
search='your search domain'>

Quentin

Revision history for this message
John Chen (john-chen2011) said :
#2

Thanks Mr. Quentin

Your explanation are really helpful !

can you give me an example of <delete model='ir.ui.menu' search='your search domain'>? sorry for trouble

as i see there are a code for adding menu in OpenErp like this:

<menuitem name="Products by Category" id="menu_virtual_product_by_category_purchase_form" action="virtual_product_category_action" parent="purchase.menu_procurement_management_product" sequence="1"/>

does the <delete model> also deleted it menu in OpenErp?> or we need to add another code for deleting the <menuitem?

Thanks Mr. Quentin

Revision history for this message
Best digitalsatori(Shine IT) (digitalsatori) said :
#3

<menuitem name="Products by Category" id="menu_virtual_product_by_category_purchase_form" action="virtual_product_category_action" parent="purchase.menu_procurement_management_product" sequence="1"/>

is just a shortcut for
    <record id="menu_virtual_product_by_category_purchase_form" model="ir.ui.menu">
      <field name="name">Products by Category</field>
      <field name="action" ref="virtual_product_category_action"/>
      <field name="parent" ref="purchase.menu_procurement_management_product"/>
      <field name="sequence">1</field>
    </record>
what it really does is to add or modify a record in the specified model table ("ir_ui_menu" in this case, menu related information is stored in this table).
whilst <delete model > is a general way to remove a record.

<delete model='ir.ui.menu' search='your search domain'> means remove a record that satisfies the stated search domain from the ir_ui_menu table.

Tony Gu

Revision history for this message
John Chen (john-chen2011) said :
#4

Thanks digitalsatori, that solved my question.

Revision history for this message
jini (mina-tyfu) said :
#5

what is a search domain? can u state a complete sample for the delete record? plz.........

Revision history for this message
Truong Vinh Trinh (truongvinhtrinh2011) said :
#6

If we do not want to display a menu, we can delete its information in the database with the following two xml commands, 1 to remove its id is stored in table "ir_model_data", 1 to clear its name stored in table "ir_ui_menu".

<delete model="ir.model.data" search="[('name','=','menu_hr_attendance_sigh_in_out')]" />
<delete model="ir.ui.menu" search="[('name','=','Sign in / Sign out')]" />

Trinh Truong
<email address hidden>

Revision history for this message
Phuc Tran Thanh (phuctran-iuerd) said :
#7

Hello,
This is not really a good idea when using name as the search domain. Note that some menus in OpenERP have the same name (Categories for example). If you use keyword name, it will delete all menus that have given name.
My suggestion: Lookup menu id in Postgres and use the domain as follow: "[('name','=','name of menu'), ('id', '=', id of menu )]"

Revision history for this message
Phuc Tran Thanh (phuctran-iuerd) said :
#8

I just found out the following code is much better
<delete id="modulename.menu" model="ir.ui.menu"/>