Skip to Content
Menu
This question has been flagged
1 Reply
11911 Views

Hi all. I'm fairly new to Odoo and I'm currently trying to set up submenus within my module. Unfortunately, it's not working. I'm getting this error:

Exception: Module loading training_module failed: file training_module\security/ir.model.access.csv could not be processed: 
No matching record found for external id 'model_trainers_trainer' in field 'Model'
Missing required value for the field 'Model' (model_id)

My ir.security.access.csv file looks like this:

id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_openacademy_openacademy,openacademy.openacademy,model_openacademy_openacademy,,1,0,0,0
access_trainers_trainer,trainers.trainer,model_trainers_trainer,,1,0,0,0

My views file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record model="ir.actions.act_window" id="trainee_action_window">
<field name="name">Trainees</field>
<field name="res_model">openacademy.openacademy</field>
<field name="view_mode">form,tree</field>
</record>
<record model="ir.actions.act_window" id="trainer_action_window">
<field name="name">Trainees 2</field>
<field name="res_model">trainers.trainer</field>
<field name="view_mode">form,tree</field>
</record>




<!-- <record id="sequence_menu_view" model="ir.ui.view">-->
<!-- <field name="name">Sequence Order</field>-->
<!-- <field name="model">openacademy.openacademy</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <form string="Sequence Order">-->
<!-- <sheet>-->
<!-- <div class="oe_title">-->
<!-- <h1>-->
<!-- <field name="sequence" readonly="1"/>-->
<!-- </h1>-->
<!-- </div>-->
<!-- </sheet>-->
<!-- </form>-->
<!-- </field>-->
<!-- </record>-->








<menuitem name="Open Academy" id="openacademy_parent_menu_id"/>
<menuitem name="Trainee Master" id="openacademy_submenu1" parent="openacademy_parent_menu_id" action="trainee_action_window"/>
<menuitem name="Trainer Master" id="openacademy_submenu2" parent="openacademy_parent_menu_id" action="trainer_action_window"/>
<!--<menuitem name="Academey" id="openacadmey_submenu3" parent="openacademy_submenu1" action="openacademy_action_window"/>-->
<!--<menuitem name="Academey2" id="openacadmey_submenu4" parent="openacademy_submenu2" action="openacademy_action_window"/>-->



<!--Action name is taken from the action we defined earlier in record model-->
<!--Don't forget to upgrade module after making changes-->
<!--Both a menu and an action are required to have the module show up in Odoo. The lowest menu item - in this case Acamey - must have the action.-->
<!--This also goes for submenus - they must also have this action on the lowest level part of the module in order to show up.-->

</data>
</odoo>

And the file of the action I'm trying to create looks like this:

from odoo import fields, models, api

class trainers(models.Model):
_name = 'trainers.trainer'

name = fields.Char()
fname = fields.Char('First Name', required=True)
profile_pic=fields.Binary()
lname=fields.Char('Last Name')


def trainer_name_concat(self):
for name in self:
fullname = fname + " " + lname
pass


I do have another working action showing up in my module (openacademy.openacademy), so I'm not sure what I'm doing wrong this time. Any advice would be appreciated. Thanks so much.

Avatar
Discard
Best Answer

Hi,

Make sure that the service has been restarted after adding the model trainers.trainer and also check the corresponding file is imported in the init file.

If you are new to odoo development, have a look at this: How To Set Access Rights For Models in Odoo


Thanks

Avatar
Discard
Author

Thank you. I ended up figuring it out yesterday; I had restarted the service and checked the init file, but that hadn't fixed the issue.

The issue ended up being three different things:

-I'd originally forgotten to add my 'trainer' model to ir.security.access

-My naming convention for models was wrong - I should have been doing "openacademy.trainer" instead of "trainers.trainer"

-Third issue was a KeyError Odoo kept returning after fixing the naming convention, and not a coding error like I had thought. Uninstalling/reinstalling the module fixed that one