Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
6081 Widoki

 

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.



Awatar
Odrzuć
Najlepsza odpowiedź

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 

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
maj 20
3585
0
sty 21
1867
1
gru 23
17314
2
sie 18
3315
0
mar 15
4480