Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

TypeError when duplicating a database with Custom Module installed (OpenERP v7)

By
Paul Strinati
on 10/14/14, 9:29 AM 929 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.

 

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 10/14/14, 10:18 AM

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?

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).

Paul Strinati
on 10/14/14, 10:40 AM

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!

Paul Strinati
on 10/20/14, 5:16 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/14/14, 9:29 AM
Seen: 929 times
Last updated: 3/16/15, 8:10 AM