I am working on Odoo 10 since a few months, I made a custom module which depends on some Odoo's modules. Today I wanted to create a user manual because my work is almost finished, so I decided to create a new data base to start from zero and be able to explain step by step how to install modules and how it works... The problem is, I get this error :
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-10.0/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-10.0/odoo/http.py", line 675, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-10.0/odoo/http.py", line 331, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-10.0/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-10.0/odoo/http.py", line 324, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-10.0/odoo/http.py", line 933, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo-10.0/odoo/http.py", line 504, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-10.0/addons/web/controllers/main.py", line 882, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/odoo/odoo-10.0/addons/web/controllers/main.py", line 870, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-10.0/odoo/api.py", line 681, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo-10.0/odoo/api.py", line 672, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo/odoo-10.0/odoo/addons/base/module/module.py", line 410, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/odoo/odoo-10.0/odoo/addons/base/module/module.py", line 484, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/odoo/odoo-10.0/odoo/modules/registry.py", line 78, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo-10.0/odoo/modules/loading.py", line 339, in load_modules
loaded_modules, update_module)
File "/opt/odoo/odoo-10.0/odoo/modules/loading.py", line 237, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo/odoo-10.0/odoo/modules/loading.py", line 135, in load_module_graph
registry.setup_models(cr, partial=True)
File "/opt/odoo/odoo-10.0/odoo/modules/registry.py", line 293, in setup_models
model._setup_fields(partial)
File "/opt/odoo/odoo-10.0/odoo/models.py", line 2836, in _setup_fields
field.setup_full(self)
File "/opt/odoo/odoo-10.0/odoo/fields.py", line 491, in setup_full
self._setup_related_full(model)
File "/opt/odoo/odoo-10.0/odoo/fields.py", line 528, in _setup_related_full
field = target._fields[name]
KeyError: 'workorder_id'
Now I am not sure but there seem to be a problem when Odoo should be importing my files because in the database my tables aren't created at all, so I don't know if they aren't created because of this error or if this error is because my tables aren't in the database. Anyway, I tried to comment where this workorder_id appears but it didn't change anything, the error is still there, I tried commenting one by one trying to restart the server and all but nothing changes. I have seen a lot of topics where they talk about inheritance but I don't think that is the case, workorder_id is my own field and it's used in my own models.
Here are the models where this field is used :
class ControlPart(models.Model):
"""
Modèle pour la vue de la pièce contrôlée.
"""
_name = 'spc.control.part'
name = fields.Char(string='Piece name')
starting_date = fields.Date(string='Starting date')
ending_date = fields.Date(string='Ending date')
basket_position = fields.Char(string='Basket position')
piece_number = fields.Integer(string='Piece number')
note = fields.Text(string='Notes')
# operation_workorder_id = fields.Many2one('spc.fabrication.order', string='Fabrication order',
# related='operation_id.workorder_id')
# operation_workorder_id_product_id = fields.Many2one('product.product', string='Product code',
# related='operation_id.workorder_id.product_id')
operation_id = fields.Many2one('spc.operation', ondelete='restrict', string='Operation')
person_id = fields.Many2one('spc.person', ondelete='restrict', string='Operator')
workcenter_id = fields.Many2one('mrp.workcenter', ondelete='restrict', string='Workcenter code')
control_measure_ids = fields.One2many('spc.control.measure', 'control_part_id', ondelete='restrict', string='Measures')
class Operation (models.Model):
"""
Modèle pour la vue des opérations.
"""
_name = 'spc.operation'
name = fields.Char(string='Operation name')
number = fields.Integer(string='Number')
pcerp_number = fields.Char(string='Pro Concept number')
#workorder_id = fields.Many2one('spc.fabrication.order', ondelete='restrict', string='Fabrication Order')
Thanks for your time !
EDIT : So after some time searching for the problem, with my colleague we didn't really find what was wrong. We suppose that Odoo didn't reload files when the service was restarted because we tried to put some wrong code in the files and Odoo simply ignored it. Maybe something was still in the memory and it kept using the same files, so we managed to resolve the problem finally by killing all the process. I hope this can still help.