Community mailing list archives

community@mail.odoo.com

error after restart if inherit is used

by
Valentin Imsand
- 04/15/2015 06:00:02
Dear Community,

I’m trying to write a simple module where I can run some special „trigger-events" when a quotation has been send… therefore I will _inherit = „sale.order“ and override the original action_quotation_send()… It works fine after a fresh installation of the new module…
from openerp.osv import fields, osv


import logging
_logger = logging.getLogger(__name__)


class hooc_main(osv.Model):
_name = "hooc.main"
_columns = {
'order_id': fields.integer('Order ID', size=4),
'product_id': fields.integer('Product ID', size=4),
'partner_id': fields.integer('Partner ID', size=4),
'assigned_to': fields.integer('Assigned To', size=9, required=False),
'followup_id': fields.integer('FollowUp ID', size=4, required=False),
'create_date': fields.date('Create Date'),
'valid_form': fields.date('Valid From', required=False),
'valid_until': fields.date('Valid Until', required=False),
'cancel_date': fields.date('Cancel Date', required=False),
'disable_ack': fields.boolean('Disable Ack'),
}


class sale_order(osv.Model):
_inherit = "sale.order"

def action_quotation_send(self, cr, uid, ids, context=None):
_logger.info('My Interrupt'),


return super(sale_order, self).action_quotation_send(cr, uid, ids, context=None)
but after a server restart, the following error appears:

Traceback (most recent call last):
  File "/Users/imsand/odoo-env/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "/Users/imsand/odoo-env/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/service/server.py", line 281, in app
    return self.app(e, s)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/http.py", line 1280, in __call__
    return self.dispatch(environ, start_response)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/http.py", line 1254, in __call__
    return self.app(environ, start_wrapped)
  File "/Users/imsand/odoo-env/lib/python2.7/site-packages/werkzeug/wsgi.py", line 588, in __call__
    return self.app(environ, start_response)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/http.py", line 1412, in dispatch
    ir_http = request.registry['ir.http']
  File "/Users/imsand/HOOC/odoo-8.0/openerp/http.py", line 339, in registry
    return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
  File "/Users/imsand/HOOC/odoo-8.0/openerp/modules/registry.py", line 353, in get
    update_module)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/modules/registry.py", line 384, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/modules/loading.py", line 351, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/modules/loading.py", line 255, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/modules/loading.py", line 152, in load_module_graph
    models = registry.load(cr, package)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/modules/registry.py", line 166, in load
    model = cls._build_model(self, cr)
  File "/Users/imsand/HOOC/odoo-8.0/openerp/models.py", line 595, in _build_model
    original_module = pool[name]._original_module if name in parents else cls._module
  File "/Users/imsand/HOOC/odoo-8.0/openerp/modules/registry.py", line 101, in __getitem__
    return self.models[model_name]
KeyError: 'sale.order'

and the server can’t start anymore… did I miss something???

Thanks for your help
Valentin