Creating a module, error on install

Asked by openT

HI, i'm currently trying to create a dummy form to learn how to create a module, but I get errors when I try installing the module

Error:

  File "/.../src/openerp-server-5.0.9/bin/tools/misc.py", line 248, in file_open
    raise IOError, 'File not found : '+str(name)
IOError: File not found : /.../src/openerp-server-5.0.9/bin/addons/medical_testform

py:

from osv import fields, osv

# Test to create a module

class clothes (osv.osv):
 _name= "medical.patient"
 _inherit = "medical.patient"
 _description= "tests"
 _columns = {
  'name_test' : fields.char ('Name Test', size=16),
  'shirt_color' : fields.char ('Shirt colors', size=8, help="Shirt"),
  'pants_color' : fields.char ('Pants colors', size=2, help="Pants"),
 }
clothes ()

------------------------------------------------------------------------------------------
__terp__

# -*- encoding: utf-8 -*-
{

 'name' : 'Medical : testform',
 'version' : '1.0',
 'author' :
 'category' : 'Generic Modules/Others',
 'depends' : ['medical'],
 'description' : """

This module was created to test the functionnalities of OpenERP and the medical module

""",
 "website" : "http://medical.sourceforge.net",
 "init_xml" : [],
 "update_xml" : ["medical_testform_view.xml",""],
 "active": False
}

------------------------------------------------------------------------------------------

import medical_testform

------------------------------------------------------------------------------------------

ir.model.access.csv (Can't find any documentation on this file, so I'm not sure about the following two lines..

id,"name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
access_medical_testform,"medical.patient","model_medical_testform","group_medical_user",1,1,1,1

------------------------------------------------------------------------------------------

xml

<?xml version="1.0" ?>
<openerp>
 <data>

 <!-- Include the TestForm_Clothing page into the Patient History -->
 <!-- Inheriting from Patient -->

  <record model="ir.ui.view" id="medical_patient_view">
   <field name="name">Patient</field>
   <field name="model">medical.patient</field>
             <field name="inherit_id" ref="medical.medical_patient_view" />
   <field name="type">form</field>
   <field name="arch" type="xml">
    <page string="TestForm">
      <field name="name_test"></field>
       <newline/>
      <field name="shirt_color"></field>
      <newline/>
      <field name="pants_color"></field>
      <newline/>
    </page>
   </field>
  </record>
 </data>
</openerp>

what's the problem?
thanks

Question information

Language:
English Edit question
Status:
Solved
For:
OpenERP Edit question
Assignee:
No assignee Edit question
Solved by:
openT
Solved:
Last query:
Last reply:
Revision history for this message
openT (useruser) said :
#1

here's the full error.

Traceback (most recent call last):
  File "src/openerp-server-5.0.9/bin/netsvc.py", line 245, in dispatch
    result = LocalService(service_name)(method, *params)
  File "src/openerp-server-5.0.9/bin/netsvc.py", line 74, in __call__
    return getattr(self, method)(*params)
  File "src/openerp-server-5.0.9/bin/service/web_services.py", line 632, in execute
    return self._execute(db, uid, wiz_id, datas, action, context)
  File "src/openerp-server-5.0.9/bin/service/web_services.py", line 612, in _execute
    return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
  File "src/openerp-server-5.0.9/bin/wizard/__init__.py", line 178, in execute
    res = self.execute_cr(cr, uid, data, state, context)
  File "src/openerp-server-5.0.9/bin/wizard/__init__.py", line 73, in execute_cr
    action_res = action(self, cr, uid, data, context)
  File "src/openerp-server-5.0.9/bin/addons/base/module/wizard/wizard_module_upgrade.py", line 92, in _upgrade_module
    db, pool = pooler.restart_pool(cr.dbname, update_module=True)
  File "src/openerp-server-5.0.9/bin/pooler.py", line 62, in restart_pool
    return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
  File "src/openerp-server-5.0.9/bin/pooler.py", line 40, in get_db_and_pool
    addons.load_modules(db, force_demo, status, update_module)
  File "src/openerp-server-5.0.9/bin/addons/__init__.py", line 740, in load_modules
    r = load_module_graph(cr, graph, status, report=report)
  File "src/openerp-server-5.0.9/bin/addons/__init__.py", line 621, in load_module_graph
    fp = tools.file_open(opj(m, filename))
  File "src/openerp-server-5.0.9/bin/tools/misc.py", line 248, in file_open
    raise IOError, 'File not found : '+str(name)
IOError: File not found : src/openerp-server-5.0.9/bin/addons/medical_testform

Revision history for this message
shanky (shankar-shinde-deactivatedaccount) said :
#2

Hello openT,
The following error suggest "medical_testform.py"  file not found.
Pls confirm name of OpenERP object  file(.py) is "medical_testform.py"
Or OpenERP style name of openERP Object is same as name of py file
ex. class project(osv.osv) and file name project.py

File "/.../src/openerp-server-5.0.9/bin/tools/misc.py", line 248, in file_open
raise IOError, 'File not found : ' str(name)
 IOError: File not found :
/.../src/openerp-server-5.0.9/bin/addons/medical_testform

On Tue, 18 May 2010 18:43:34 -0000, Open Tan wrote:
New question #111496 on OpenERP:
  > https://answers.launchpad.net/openerp/ question/111496
  >
  > HI, i'm currently trying to create a dummy form to learn how to
create a module, but I get errors when I try installing the module
  >
  > Error:
  >
  > File "/.../src/openerp-server-5.0.9/bin/tools/misc.py", line 248,
in file_open
  > raise IOError, 'File not found : ' str(name)
  > IOError: File not found :
/.../src/openerp-server-5.0.9/bin/addons/medical_testform
  >
  > py:
  >
  > from osv import fields, osv
  >
  > # Test to create a module
  >
  > class clothes (osv.osv):
  > _name= "medical.patient"
  > _inherit = "medical.patient"
  > _description= "tests"
  > _columns = {
  > 'name_test' : fields.char ('Name Test', size=16),
  > 'shirt_color' : fields.char ('Shirt colors', size=8, help="Shirt"),
  > 'pants_color' : fields.char ('Pants colors', size=2, help="Pants"),
  > }
  > clothes ()
  >
  >
  >
------------------------------------------------------------------------------------------
  > __terp__
  >
  >
  > # -*- encoding: utf-8 -*-
  > {
  >
  > 'name' : 'Medical : testform',
  > 'version' : '1.0',
  > 'author' :
  > 'category' : 'Generic Modules/Others',
  > 'depends' : ['medical'],
  > 'description' : """
  >
  > This module was created to test the functionnalities of OpenERP and
the medical module
  >
  > """,
  > "website" : "http://medical.sourceforge.net",
  > "init_xml" : [],
  > "update_xml" : ["medical_testform_view.xml",""],
  > "active": False
  > }
  >
  >
------------------------------------------------------------------------------------------
  >
  > import medical_testform
  >
  >
------------------------------------------------------------------------------------------
  >
  > ir.model.access.csv (Can't find any documentation on this file, so
I'm not sure about the following two lines..
  >
  >
id,"name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
  >
access_medical_testform,"medical.patient","model_medical_testform","group_medical_user",1,1,1,1
  >
  >
------------------------------------------------------------------------------------------
  >
  > xml
  >
  >
  > <?xml version="1.0" ?>
  > <openerp>
  > <data>
  >
  > <!-- Include the TestForm_Clothing page into the Patient History -->
  > <!-- Inheriting from Patient -->
  >
  > <record model="ir.ui.view" id="medical_patient_view">
  > <field name="name">Patient</field>
  > <field name="model">medical.patient</field>
  > <field name="inherit_id" ref="medical.medical_patient_view" />
  > <field name="type">form</field>
  > <field name="arch" type="xml">
  > <page string="TestForm">
  > <field name="name_test"></field>
  > <newline/>
  > <field name="shirt_color"></field>
  > <newline/>
  > <field name="pants_color"></field>
  > <newline/>
  > </page>
  > </field>
  > </record>
  > </data>
  > </openerp>
  >
  > what's the problem?
  > thanks
  >
  > You received this question notification because you are an answer
  > contact for OpenERP.
  >
  >

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) said :
#3

Hello OpenT,

It could be the issue of medical_testform_view.xml file not listed under your module.

Moreover, you should have written import FILENAME in your __init__.py and the module should have FILENAME.py file.

Thanks.

Revision history for this message
openT (useruser) said :
#4

Hi,

I tried remove the extra quotes (in __terp__) and changed the filenames in each files to make sure they were the same (medical_testform -> medical_test)

OLD$ filename : medical_testform.py
NEW$ filename : medical_test.py

**********__terp__.py********
OLD$> "update_xml" : ["medical_testform_view.xml",""],

to

NEW$> "update_xml" : ["medical_test_view.xml"],

**********__init__.py********
import medical_test

With the changed mentionned before, I also moved my Eclipse workspace (I work with the pyDev plugin) to a path that wasn't as long (I think the problem was probably the filenames though).

Old path: /home/likewise-open/my_domain_name/my_username/erp_py/workspace/erp_serv/src/openerp-server-5.0.9/bin/addons

NEW path: /Eclipse/workspace/erp_serv/src/openerp-server-5.0.9/bin/addons

I can now install the module without any errors, thanks for the replies.

@shanky :

// quote
Or OpenERP style name of openERP Object is same as name of py file
ex. class project(osv.osv) and file name project.py

//
Why do you suggest that the class name has the be the same as the filename?