This question has been flagged
1 Reply
4161 Views

I have a custom Module that adds functionality to Instant Messaging [im_chat]. And naturally my module depends on [im_chat] being installed.

Eventhough [im_chat] is installed, still I get an error message when I want to install my Module [im_chat_history] that somewhat implies [im_chat] was not installed

2014-10-23 13:20:39,427 1691 CRITICAL odoo-8_test openerp.modules.module: Couldn't load module im_chat_history
2014-10-23 13:20:39,427 1691 CRITICAL odoo-8_test openerp.modules.module: No module named im_chat

I have an __init__.py in my Module that imports the im_chat Module

__init__.py

import im_chat

And it looks to me (having no skills of coding and/or python) odoo fails to do that (importing im_chat).

Does anybody has a hint, what could be wrong here?

 

============== the code =======================

 

im.py

from openerp.osv import fields,osv

class im_history(osv.osv):
    _inherit = 'im.message'


im_history()

 

 

im_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
      <record id="view_im_history" model="ir.ui.view">
        <field name="name">im.message.tree</field>
        <field name="model">im.message</field>
        <field name="arch" type="xml">
                <tree string="IM">
                    <field name="date"/>
                    <field name="from_id"/>
                    <field name="to_id"/>
                    <field name="message"/>
                </tree>
        </field>
      </record>

      <!-- Top menu item -->
        <menuitem name="IM"
            id="im_history_root"
            groups="base.group_user"
            sequence="10"/>

        <record id="open_view_im_history" model="ir.actions.act_window">
            <field name="name">Instant messaging history</field>
            <field name="res_model">im.message</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="view_im_history"/>
        </record>

        <menuitem name="Actions" id="im_history" parent="im_history_root" groups="base.group_user"/>
        <menuitem action="open_view_im_history" id="menu_open_view_im_history" parent="im_history" sequence="20" groups="base.group_user"/>


    </data>
</openerp>

 


__init__.py

import im

 

 

__openerp__.py

{
    "name" : "Instant messaging history",
    "version" : "1.1",
    "author" : "L",
    "category" : "Generic Modules/Messaging",
    "website" : "-",
    "description": "Adds history view to instant messaging module.",
    "depends" : ["im_chat"],
    "init_xml" : [],
    "update_xml" : ["im_view.xml"],
    "installable": True
}

 

Avatar
Discard

I had some similar errors with custom modules while putting the python dependencies at __openerp__.py Removing those dependencies from __openerp__.py fixed the problem for me. Hope it could help you too.. Cheers

Author

apparently that was not it. Removed a line that lists the dependency of [im_chat] but still get the same error File "/opt/odoo/odoo-server/addons-custom/im_chat_history/__init__.py", line 1, in import im_chat ImportError: No module named im_chat

Best Answer

In contrary to regular python, importing other Odoo modules is done using the __openerp__.py file. Remove the "import" line from your __init__.py file. Only add to that file the actual python files in your custom module directory, nothing else.

Instead, edit the __openerp__.py file and find the key "depends". In a list, sum up all the modules by their directory name that you require from Odoo to work.

For example:
"depends": ['account', 'sale', 'im_chat']

Avatar
Discard
Author

thanks, that helped with the "No Module named 'xy'" Problem. Now I am getting a " KeyError: 'im.message' " . I find the string 'im.message' in two of my Module's files: 1. 'im_view.xml' & 2. 'im.py'. I have posted the code in my Question above for reference

In my current Odoo version there is no im.message in the source code. There is however a "im_chat.message" available. Check if this is the class you require OR the model is in a different Odoo module.