跳至內容
選單
此問題已被標幟
2 回覆
4952 瀏覽次數

Hi all,

I am trying to create menu item in new module and display it in manufacturing module in Master Data tab. I have defined menu item and security file but still menu item is not shown.

Here is my code:

models.py

class GearManufacturing(models.Model):
_name = 'gear.manufacturing'
product_tmpl_id = fields.Many2one('product.template', 'Product',
domain="[('type', 'in', ['product', 'consu'])]", required=True)
model = fields.Many2one('product.template', 'Model',required=True)
product_to_dispatch = fields.Integer('Products to Dispatch')
dispatch_date = fields.Datetime('Dispatch Date', copy=False, default=fields.Datetime.now, index=True, required=True)

views.xml
<odoo>
<data>
<!-- explicit list view definition -->
<record model="ir.ui.view" id="gear_manufacturing.list">
<field name="name">GearManufacturing list</field>
<field name="model">gear.manufacturing</field>
<field name="arch" type="xml">
<tree>
<field name="product_tmpl_id"/>
<field name="product_to_dispatch"/>
<field name="dispatch_date"/>
</tree>
</field>
</record>
<!-- actions opening views on models -->
<record model="ir.actions.act_window" id="gear_manufacturing.action_window">
<field name="name">GearManufacturing window</field>
<field name="res_model">gear.manufacturing</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem name="Honda Dispatch Plan" parent="mrp.menu_mrp_bom" id="menu_honda_dispatch_plan"
action="gear_manufacturing.action_window" groups="base.group_user"/>
</data>
</odoo>

ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_gear_manufacturing_gear_manufacturing,gear_manufacturing.gear_manufacturing,model_gear_manufacturing_gear_manufacturing,,1,0,0,0
access_gear_manufacturing_gear_manufacturing,gear_manufacturing.gear_manufacturing,model_gear_manufacturing_gear_manufacturing,base.group_user,1,1,1,0
What's wrong in this code. Kindly assist me
頭像
捨棄
最佳答案

 Hi,

  Change the model id in the    ir.model.access.csv to  model_gear_manufacturing not model_gear_manufacturing_gear_manufacturing


UPDT : Change the view


<record id="gear_manufacturing_tree" model="ir.ui.view">
<field name="name">gear.manufacturing.tree</field>
<field name="model">gear.manufacturing</field>
<field name="arch" type="xml">
<tree>
<field name="product_tmpl_id"/>
<field name="product_to_dispatch"/>
<field name="dispatch_date"/>
</tree>
</field>
</record>

<record model="ir.actions.act_window" id="gear_manufacturing_action">
<field name="name">GearManufacturing window</field>
<field name="res_model">gear.manufacturing</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem name="Honda Dispatch Plan" parent="mrp.menu_mrp_bom" id="menu_honda_dispatch_plan"
groups="base.group_user" action="gear_manufacturing_action"/>

   CSV 


id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_gear_manufacturing_gear_manufacturing,gear_manufacturing.gear_manufacturing,model_gear_manufacturing,base.group_user,1,1,1,0

頭像
捨棄
作者

Thanks for pointing out! but unfortunately the menu item still not appears

Hi,

Make sure yo have added the security file in the manifest

作者

It's working now, thanks

最佳答案

Hi,

Please try this,

<menuitem name="Honda Dispatch " parent="mrp.menu_mrp_bom" id="menu_honda_dispatch_plan_parent"
 groups="base.group_user"/>

<menuitem name="Honda Dispatch Plan" parent="menu_honda_dispatch_plan_parent" id="menu_honda_dispatch_plan"
action="gear_manufacturing.action_window" groups="base.group_user"/>

and make sure 'mrp' in your depends [manifest]

Thanks

Aswini - iWesabe

頭像
捨棄
作者

I tried this above solution but its not working

相關帖文 回覆 瀏覽次數 活動
0
12月 24
1119
2
10月 20
5260
4
10月 19
33796
1
4月 17
3912
2
3月 15
7320