[Python] How to Fix ValueError: External ID not found in the system in Odoo?

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    Having code error

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

    The above server error caused the following client error: RPC_ERROR: Odoo Server Error RPC_ERROR at makeErrorFromResponse (http://localhost:8069/web/assets/12166fe/web.assets_web.min.js:3140:163) at XMLHttpRequest.<anonymous> (http://localhost:8069/web/assets/12166fe/web.assets_web.min.js:3145:13)

    code

    models/hospital_patient.py

    `from odoo import models, fields

    class HospitalPatient(models.Model):
    _name = 'hospital.patient'
    _description = 'Hospital Patient'

    name = fields.Char(string='Patient Name', required=True)
    age = fields.Integer(string='Age')
    gender = fields.Selection([('male', 'Male'), ('female', 'Female')], string='Gender')
    disease = fields.Char(string='Disease')


    hospital_patient_views.xml

    <odoo><data>
    <record id="view_hospital_patient_tree" model="ir.ui.view">
    <field name="name">hospital.patient.tree</field>
    <field name="model">hospital.patient</field>
    <field name="arch" type="xml">
    <tree>
    <field name="name"/>
    <field name="age"/>
    <field name="gender"/>
    <field name="disease"/>
    </tree>
    </field>
    </record>
    <record id="view_hospital_patient_form" model="ir.ui.view">
    <field name="name">hospital.patient.form</field>
    <field name="model">hospital.patient</field>
    <field name="arch" type="xml">
    <form>
    <sheet>
    <group>
    <field name="name"/>
    <field name="age"/>
    <field name="gender"/>
    <field name="disease"/>
    </group>
    </sheet>
    </form>
    </field>
    </record>
    <record id="model_hospital_patient" model="ir.model">
    <field name="name">hospital.patient</field>
    <field name="model">hospital.patient</field>
    <field name="state">manual</field>
    </record>
    <menuitem id="menu_hospital_management_root" name="Hospital Management"/>
    <menuitem id="menu_hospital_patient" name="Patients" parent="menu_hospital_management_root" action="action_hospital_patient"/>
    </data></odoo>


    security/ir.model.access.csv

    id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
    access_hospital_patient,hospital_patient,model_hospital_patient,,1,1,1,1

    Continue reading...

Compartilhe esta Página