コンテンツへスキップ
メニュー
この質問にフラグが付けられました

Hello.

 I am trying to import a module on to my database in Odoo.com. I've entered everything correctly and verified the files and there's no problems in the code. However, when I try to import the module, I get errors regarding the model I'm linking the XML views to.

For example:


Error while importing module 'my_module'. 

    while parsing /tmp/tmpg3vj2tty/my_module/views/my_module_menus.xml:4, somewhere inside <menuitem id="my_module_submenu" name="Module Menu" parent="my_module_menu" action="my_module_action" sequence="2"/>  


and:


while parsing /tmp/tmpsrcr391x/my_module/views/my_module_lists.xml:3 Error while validating view near: <list string="My Module" __validate__="1"> <field name="name"/>

Model not found: my.module 

View error context: {'file': '/tmp/tmpsrcr391x/my_module/views/my_module_lists.xml', 'line': 1, 'name': 'my.module.list', 'view': ir.ui.view(3161,), 'view.model': 'my.module', 'view.parent': ir.ui.view(), 'xmlid': 'my_module_list'}  


What's strange about this is that it everything works perfectly fine on my localhost server, which is where I made the module. I think it has something to do with the models but I don't know what could be wrong. How can this be fixed?

アバター
破棄
最善の回答

It looks like your module isn't correctly finding the model definition when installed on Odoo.com, even though it works locally.



  First, ensure your model is correctly defined in a Python file (e.g., `models/my_model.py`) within your module.

  Make sure the Python file containing the model is imported in your module's `__init__.py` file. For example, `from . import my_model`.

  Verify that the model name in your Python file matches exactly with what you're using in your XML views (e.g., `my.module`). Typos are a common cause of this issue.

  Confirm that the module is correctly declared as a dependency in the `__manifest__.py` file if it relies on other modules.

  After making changes, try upgrading the module on your Odoo.com instance rather than reinstalling it. This can sometimes resolve issues related to module loading order.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

アバター
破棄
最善の回答

Uninstall locally and try re-installing it. I'm quite certain it will not work there either. This behavior can easily occur when you update your module 'as you go' - i.e. installed early in development, changed things around. At one point you have a module that works because it has been installed already early on and views referenced to somewhere else for example are in the database already. 

That being said, check out closely

<menuitem id="my_module_submenu" name="Module Menu" parent="my_module_menu" action="my_module_action" sequence="2"/>

Your menuitem my_module_submenu most likely references the action my_module_action before it is actually defined (-> move the record of my_module_action above the menuitem needing it).

For my_module_lists.xml it's just a guessing game. Post your code at it probably can be solved as well.

アバター
破棄
関連投稿 返信 ビュー 活動
0
2月 25
1482
0
1月 25
1829
1
1月 25
1512
2
7月 25
3904
0
5月 25
1301