安装模块时 Odoo 10 KeyError
Odoo 10 KeyError when installing module
几个月以来我一直在使用 Odoo 10,我制作了一个自定义模块,它依赖于一些 Odoo 的模块。
今天我想创建一个用户手册,因为我的工作快完成了,所以我决定创建一个新的数据库,从零开始,能够一步一步地解释如何安装模块以及它是如何工作的……
问题是,我收到此错误:
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'
现在我不确定,但是当 Odoo 应该导入我的文件时似乎有问题,因为在数据库中我的表根本没有创建,所以我不知道它们是否没有创建,因为这个错误或者这个错误是因为我的表不在数据库中。
不管怎样,我试着评论这个 workorder_id 出现的地方,但它没有改变任何东西,错误仍然存在,我试着一个一个地评论试图重新启动服务器,但几乎没有任何改变。
我看过很多讨论继承的话题,但我不认为是这样,workorder_id是我自己的领域,它被用在我自己的模型中。
以下是使用此字段的模型:
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')
感谢您的宝贵时间!
编辑:
因此,在与我的同事一起寻找问题一段时间后,我们并没有真正发现问题所在。我们假设 Odoo 在服务重启时没有重新加载文件,因为我们试图在文件中放入一些错误的代码,而 Odoo 只是忽略了它。
也许某些东西仍在内存中并且它一直在使用相同的文件,所以我们设法通过杀死所有进程最终解决了这个问题。
我希望这仍然可以提供帮助。
这是我解决问题的方法,这不是一个很好的解决方案,但这是我们找到的唯一方法:
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.
几个月以来我一直在使用 Odoo 10,我制作了一个自定义模块,它依赖于一些 Odoo 的模块。 今天我想创建一个用户手册,因为我的工作快完成了,所以我决定创建一个新的数据库,从零开始,能够一步一步地解释如何安装模块以及它是如何工作的…… 问题是,我收到此错误:
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'
现在我不确定,但是当 Odoo 应该导入我的文件时似乎有问题,因为在数据库中我的表根本没有创建,所以我不知道它们是否没有创建,因为这个错误或者这个错误是因为我的表不在数据库中。 不管怎样,我试着评论这个 workorder_id 出现的地方,但它没有改变任何东西,错误仍然存在,我试着一个一个地评论试图重新启动服务器,但几乎没有任何改变。 我看过很多讨论继承的话题,但我不认为是这样,workorder_id是我自己的领域,它被用在我自己的模型中。
以下是使用此字段的模型:
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')
感谢您的宝贵时间!
编辑: 因此,在与我的同事一起寻找问题一段时间后,我们并没有真正发现问题所在。我们假设 Odoo 在服务重启时没有重新加载文件,因为我们试图在文件中放入一些错误的代码,而 Odoo 只是忽略了它。 也许某些东西仍在内存中并且它一直在使用相同的文件,所以我们设法通过杀死所有进程最终解决了这个问题。 我希望这仍然可以提供帮助。
这是我解决问题的方法,这不是一个很好的解决方案,但这是我们找到的唯一方法:
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.