Skip to Content
Menú
This question has been flagged
2 Respostes
4891 Vistes

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
Avatar
Descartar
Best Answer

 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

Avatar
Descartar
Autor

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

Hi,

Make sure yo have added the security file in the manifest

Autor

It's working now, thanks

Best Answer

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

Avatar
Descartar
Autor

I tried this above solution but its not working

Related Posts Respostes Vistes Activitat
0
de des. 24
1073
2
d’oct. 20
5211
4
d’oct. 19
33690
1
d’abr. 17
3840
2
de març 15
7253