odoo 8 - missing error - can't create contact with prototype inheritance

1.7k views Asked by At

I encountered the following Error on creating a partner in odoo 8:

MissingError

One of the documents you are trying to access has been deleted, please try again after refreshing.

Http Traceback:

2015-06-09 10:32:37,377 1344 ERROR #db-name# openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/opt/odoo/openerp/http.py", line 526, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/openerp/http.py", line 563, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/openerp/http.py", line 303, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/openerp/http.py", line 300, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoo/openerp/http.py", line 792, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/openerp/http.py", line 396, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/addons/web/controllers/main.py", line 949, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/addons/web/controllers/main.py", line 941, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 336, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/openerp/addons/base/res/res_partner.py", line 569, in create
    partner = super(res_partner, self).create(vals)
  File "/opt/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 462, in new_api
    result = method(self._model, cr, uid, *args, **kwargs)
  File "/opt/odoo/addons/mail/mail_thread.py", line 377, in create
    thread_id = super(mail_thread, self).create(cr, uid, values, context=context)
  File "/opt/odoo/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 336, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 4025, in create
    record = self.browse(self._create(old_vals))
  File "/opt/odoo/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/api.py", line 462, in new_api
    result = method(self._model, cr, uid, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 4226, in _create
    self.pool[model_name]._store_set_values(cr, user, ids, fields2, context)
  File "/opt/odoo/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 4335, in _store_set_values
    result = self._columns[val[0]].get(cr, self, ids, val, SUPERUSER_ID, context=context)
  File "/opt/odoo/openerp/osv/fields.py", line 1361, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/opt/odoo/addons/account_followup/account_followup.py", line 137, in _get_latest
    amls = partner.unreconciled_aml_ids
  File "/opt/odoo/openerp/fields.py", line 765, in __get__
    return record._cache[self]
  File "/opt/odoo/openerp/models.py", line 5852, in __getitem__
    return value.get() if isinstance(value, SpecialValue) else value
  File "/opt/odoo/openerp/fields.py", line 53, in get
    raise self.exception
MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')
2015-06-09 10:32:37,379 1344 INFO #db-name# werkzeug: #ip# - - [09/Jun/2015 10:32:37] "POST /web/dataset/call_kw/res.partner/create HTTP/1.1" 200 -

The context: I develop a new module and want to inherit res.partner for a few models. I narrowed it down by taking all models out of the __init__.py except this testmodel:

# -*- coding: utf-8 -*-
from openerp import fields, models

class Testmodel(models.Model):
    _name = 'module_name.testmodel'
    _inherit = 'res.partner'

I have also taken all views out of the __openerp__.py.

It seems that the inheritance is the cause for this problem. I tried to change it into _inherits = {'res.partner': 'partner_id'} and then the error is not showing anymore, but I don't want that kind of inheritance. My desired outcome is a testmodel with all fields of res.partner but as a separate model in the database, like what in this image is called prototype inheritance: https://odoo-80.readthedocs.org/en/latest/reference/orm.html

The same Error Message shows up if I edit an existing partner and try to assign an existing parent company to it.

2

There are 2 answers

1
Soaad On BEST ANSWER

Try to depend on res.partner in your manifest file :)

in __openerp__.py
{...
'depends': ["base",],
...
}
0
Marie Pizzer On

I had a similar issue when inheriting from project.task and it resulted to be a bug. I solved it by editing the function _hours_get (in your case, it would be _get_latest). The function was accessing a result from a database query which was null, but it was not validating what that result contained.

So I hope you can solve your issue by correcting the code in _get_latest.