我是 Odoo 的新手。创建了一个简单的自定义模块。它工作正常,直到我将 xml 文件分成两部分。尝试升级我的自定义模块时出现以下错误:
上述异常是导致以下异常的直接原因:
Traceback (most recent call last):
File "D:\Odoo\Odoo_15\odoo\odoo\http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "D:\Odoo\Odoo_15\odoo\odoo\http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing file:/d:/odoo/odoo_15/custom_addons/om_hospital/views/menu.xml:17, somewhere inside
<menuitem id="menu_patient" name="Patient" action="action_hospital_patient" parent="menu_patient_master" sequence="0"/>
以下是代码:
清单.py:
{
'name': 'Custom Hospital Management by Milon',
'version': '1.0.0',
'category': 'Hospital Maanagement',
'author': 'Milon Sarker',
'summary': 'Its a custom system',
'description': 'Its a custom system bro',
'depends': [],
'data': [
'views/menu.xml',
'views/patient_view.xml',
],
'installable': True,
'auto_install': False,
'application': True,
'sequence': -100
}
模型:患者.py:
from odoo import api, fields, models
class hospitalPatient(models.Model):
_name = 'hospital.patient'
_description = 'Hospital Patient'
name = fields.Char(string = 'Name')
age = fields.Integer(string = "Age")
gender = fields.Selection([('male','Male'), ('female', 'Female')], string = "Gender")
菜单.xml:
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<menuitem id = "menu_hospital_root"
name = "Hospital"
sequence = "0"
/>
<menuitem id = "menu_patient_master"
name = "Patient Details"
parent = "menu_hospital_root"
sequence = "0"
/>
<menuitem id="menu_patient"
name="Patient"
action="action_hospital_patient"
parent="menu_patient_master"
sequence="0"
/>
</odoo>
患者_view.xml:
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id = "action_hospital_patient" model = "ir.actions.act_window">
<field name="name">Patients</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hospital.patient</field>
<field name="view_mode">tree,form,</field>
<field name="context">{}</field>
<field name="help" type = "html">
<p class = "o_view_nocontent_smiling_face">
Create your first patient!
</p>
</field>
</record>
</odoo>
实际上,我不知道问题的根本原因,但以下是我的解决方法:
'data':[
'security/ir.model.access.csv',
# Define action in patient views before their references
'views/patient_view.xml',
'views/menu.xml', # Last because referencing actions defined in previous files
],
P/s:也许我们面临这个问题是因为我们已经按照教程视频“5.如何在 Odoo 中创建窗口操作 || Odoo 中的操作 - https://www.youtube.com”创建了操作“action_hospital_ Patient” /watch?v=XcVMcJYHuzc&list=PLqRRLx0cl0homY1elJbSoWfeQbRKJ-oPO&index=5"