This question has been flagged
2 Replies
2547 Views

I've created a very simple custom module to add a boolean field to the hr_expense_line as follows:

__init__.py:

import ocl_hr_expense

 

__openerp__.py:

{
    'name': "OCL HR Expense Additions",
    'version': "1.0",
    'author': "Paul Strinati",
    'category': "Tools",
    'depends': ['hr'],
    'data': ['ocl_hr_expense.xml'],
    'demo': [],
    'installable': True,
}

ocl_hr_expense.py:

from openerp.osv import fields, osv
class ocl_hr_expense(osv.osv):
    _inherit = "hr.expense.line"
    _columns = {
        'abc': fields.boolean('ABC Reportable')
    }
    _defaults ={
        'abc': 0
    }
ocl_hr_expense()

ocl_hr_expense.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="ocl_hr_expense">
      <field name="name">hr.expense.line.tree</field>
      <field name="model">hr.expense.expense</field>
      <field name="inherit_id" ref="hr_expense.view_expenses_form" />
      <field name="arch" type="xml">
        <xpath expr="/form/sheet/notebook/page[@string='Description']/field[@name='line_ids']/tree[@string='Expense Lines']/field[@name='name']" position="after">
          <field name="abc" />
        </xpath>
      </field>
    </record>
  </data>
</openerp>

So far...so good!

The above was done in a test environment called ERP_TEST_IT2 (the DB is duplicated from ERP_LIVE, our live DB, but running off the same filesystem files). Before making any more changes, I want to duplicate this test environment to ERP_TEST_IT3 - I did so via the Manage Databases link on the login page, and having successully supplied the Master password I can see that the new DB instance has been created (and I can see the boolean field in hr_expense_line, as expected).

However, when I try to login to the new ERP_TEST_IT3 environment, I get the following error message:

Client Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/http.py", line 204, in dispatch
    response["result"] = method(self, **self.params)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 864, in authenticate
    req.session.authenticate(db, login, password, env)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 115, in authenticate
    uid = self.proxy('common').authenticate(db, login, password, env)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 30, in proxy_method
    result = self.session.send(self.service_name, method, *args)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 103, in send
    raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)


Server Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 433, in dispatch
    return fn(*params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 444, in exp_authenticate
    res_users = pooler.get_pool(db).get('res.users')
  File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 49, in get_pool
    return get_db_and_pool(db_name, force_demo, status, update_module)[1]
  File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 203, in get
    update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 233, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 350, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 256, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 161, in load_module_graph
    models = pool.load(cr, package)
  File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 118, in load
    model = cls.create_instance(self, cr)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 883, in create_instance
    'You may need to add a dependency on the parent class\' module.' % (name, parent_name))
TypeError: The model "hr.expense.line" specifies an unexisting parent class "hr.expense.line"
You may need to add a dependency on the parent class' module.

I then get "Invalid username or password".

Flicking back to ERP_TEST_IT2 I can log in fine.

Is there a trick to duplicating a DB with custom modules?

I've seen posts for similar errors, although not related to having duplicated the DB:

https://www.odoo.com/forum/help-1/question/typeerror-the-model-fleet-vehicle-specifies-an-unexisting-parent-class-fleet-vehicle-17854

and

https://www.odoo.com/forum/help-1/question/getting-typeerror-the-model-hr-contract-specifies-an-unexisting-parent-class-hr-contract-53061

but unfortunately no answers.

Any pointers greatly appreciated, as I've tried deleting and re-duplicating the DB but to no avail.

 

Avatar
Discard
Best Answer

A thing to try:

  • pg_dump the database commandline (use format=c , no-owner / etc.)
  • create database clone in psql
  • pg_restore the database into just-created database
  • run odoo with flag "-d clone -u all", which loads your database and tries to update all modules

Have you tried creating a new empty database and then installing your module as well?

Avatar
Discard
Author

Will try this - but being new to postgresql I'm not up to speed with the syntax on the command line etc. (I've been using pgAdmin III to view the schema etc).

Author

Haven't forgotten about this - have just built a new server and restored our live db from backup, so will hopefully be able to try the above later today - will let you know how it goes!