Odoo无法在菜单中添加新的menuitem

时间:2017-09-08 08:31:58

标签: view openerp menuitem odoo-9

我正在尝试将新的menuitem添加到购买菜单中,如下图中的“购买”: enter image description here

我的 openerp .py:

"depends": [
    "purchase",
    "product",
    "base",
],

查看

    <menuitem id="test" name="Test menu"
        parent="base.menu_purchase_root" sequence="2" />

没有任何反应,没有错误,我无法在购买菜单中看到此菜单项。

可能是什么问题?

2 个答案:

答案 0 :(得分:4)

我认为如果没有action或子菜单,Odoo将不会显示您的菜单。

答案 1 :(得分:2)

您必须在菜单中添加操作,例如购买时定义。例如:

 <menuitem
        action="product.product_category_action_form" id="menu_product_category_config_purchase"
        parent="purchase.menu_product_in_config_purchase" sequence="1" />

您可以在购买&gt;&gt;下面看到此菜单配置&gt;&gt;产品&gt;&gt;产品类别

此操作是通过其ID从产品中获取的。如果要定义自定义操作,则可以这样定义:

 <record id="product_normal_action_puchased" model="ir.actions.act_window">
    <field name="name">Products</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">product.template</field>
    <field name="view_type">form</field>
    <field name="view_mode">kanban,tree,form</field>
    <field name="context">{"search_default_filter_to_purchase":1}</field>
    <field name="search_view_id" eval="False"/> <!-- Force empty -->
    <field name="view_id" eval="False"/> <!-- Force empty -->
    <field name="help" type="html">
      <p class="oe_view_nocontent_create">
        Click to define a new product.
      </p><p>
        You must define a product for everything you purchase, whether
        it's a physical product, a consumable or services you buy to
        subcontractors.
      </p><p>
        The product form contains detailed information to improve the
        purchase process: prices, procurement logistics, accounting data,
        available vendors, etc.
      </p>
    </field>
</record>

现在,在定义自定义操作后,将它的ID设置为您的菜单:

      <!-- Product menu-->
  <menuitem name="Products" id="menu_procurement_partner_contact_form" action="product_normal_action_puchased"
      parent="menu_procurement_management" sequence="20"/>

通过这种方式,您可以添加菜单,然后在定义操作时需要在 view_id 下添加视图。这有助于在单击特定菜单后打开视图。