Odoo Custom Module - First Steps failed by model_id

40 views Asked by At

on my work we have a new ERP-System with based on odoo. I have tried to write my own module to try to understand the workwise of odoo, but it fails by the file ir.model.access.csv and i don´t know what is the issue. Here are my files: music.py

from odoo import fields, models

class Music(models.Model):
    _name = "music"
    _description = "This is Music"

    name = fields.Char("Name")
    title = fields.Char("Title")
    genre = fields.Char("Genre")

my view:

    <odoo>
    <data>
        <!--name, model und arch bezieht sich auf irgendwas im model ir.ui.view-->
        <!--name = eindeutiger name-->
        <!--model = der angegebene name in der Klasse-->
        <record id="music_tree_view" model="ir.ui.view">
            <field name="name">music.tree.view</field>
            <field name="model">music</field>
            <field name="arch" type="xml">
                <tree>
                    <field name="name"/>
                    <field name="title"/>
                </tree>
            </field>
        </record>

        <record id="music_form_view" model="ir.ui.view">
            <field name="name">music.form.view</field>
            <field name="model">music</field>
            <field name="arch" type="xml">
                <form string="Music">
                    <group>
                        <field name="name"/>
                        <field name="title"/>
                        <field name="genre"/>
                    </group>
                </form>
            </field>
        </record>

        <record id="music_action" model="ir.actions.act_window">
            <field name="name">Music</field>
            <field name="res_model">music</field>
            <field name="view_mode">tree,form</field>
        </record>

        <menuItem id="music_root_menu"
                    name="Music"
                    />
        
        <menuItem id="music_sub_root_menu"
                    name="All My Music"
                    parent="music_root_menu"
                    />
        
        <menuItem id="music_sub_root_menu"
                    action="music_action"
                    name="My Music List"
                    parent="music_sub_root_menu"
                    />

    </data>
</odoo>

and the file ir.model.access.csv

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_music,music,model_music,base.group_user,1,1,1,1

Do you need the other files too for help?

The exception is:

Exception: Laden des Moduls Music fehlgeschlagen: Datei Music\security/ir.model.access.csv konnte nicht verarbeitet werden
Kein passender Datensatz für externe ID „model_music.music“ in Feld „Model“ gefunden
Ein erforderlicher Wert für das Feld „Model“ (model_id) fehlt.

=> no value for the field model_id.

Can anyone help me?

1

There are 1 answers

2
CZoellner On

I think that is a special case when having only one word for a model name or just no . (dot) in the name of a model. On import something weird is happening and odoo tries to find an external id of a model which isn't there: model_music.music. I don't know the name of your module, but it should be something like my_module.model_music.

I've only found 2 to 3 models without . in Odoo's code, for example the model website in the website module. And odoo used the fully qualified external id for this model in its security file. So just try to do that, too:

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_music,music,my_module.model_music,base.group_user,1,1,1,1