Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
7224 มุมมอง

 

I'm developing a custom module, I just started coding the view I have a context error with my variables, how can I solve this:
 
record "student_action" model="ir.actions.act_window">
field "name">
student
​field "res_model">
iti.student
record​

menuitem "iti_root" name="iti"/>
menuitem "iti_student_menu"
name="student"
​   parent = "iti_root" action="student_action"/>

and my model is:

from odoo.odoo import models, fields
class ItiStudent(models.Model):
_name ="iti.student"


and the message error is :

odoo.tools.convert.ParseError: while parsing 
file:/e:/odoo/odoo15/custom_moduls/iti/views/iti_student_views.xml:4 Invalid model name 'iti.student' in action definition. View error context: '-no context-'


 I can't find where the problem is.



อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I have met this same error info by the following mistake...

 for one line in the tree/list view, the typo of "optional" with "option"


field name="state" widget='badge' optional="show"/

this kind of "no hints" error is really hard to debug... I commented out the blocks line by line and finally find the mistake in last line 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

The error message indicates that there is an issue with the model name in your action definition. The model name should be in the format module_name.model_name.

In XML:
<record model="ir.actions.act_window" id="student_action">
    <field name="name">student</field>
<field name="res_model">iti.student</field>
</record>

<menuitem name="iti" id="iti_root"/>
<menuitem name="student" id="iti_student_menu" parent="iti_root" action="student_action"/>

In Python:
from odoo import models, fields

class ItiStudent(models.Model):
    _name = "iti.student"

Hope it helps

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

HI,

It seems something wrong with the xml file or with the created model. In order to sort it out, you can do as follows:

* comment/remove the importing of XML files from the manifest file and upgrade your module
* see if you can see the added model in Settings -> Database Structure -> Models
* If not found ensure the files are imported in the init file

* if the model is added to the db, try uncommenting the xml import from manifest and upgrade module.

Sample ir.actions.act_window : https://github.com/odoomates/odooapps/blob/16.0/om_hospital/views/patient_view.xml


Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 20
3933
0
ม.ค. 21
2225
Multiple Create Form Views same Model แก้ไขแล้ว
1
ธ.ค. 23
17931
fields context no working แก้ไขแล้ว
2
ส.ค. 18
3779
0
มี.ค. 15
4970