0

我正在处理员工数据,例如在 python 中:

employee_id = fields.Many2one('hr.employee', string="Работник")
work_location = fields.Char(related='employee_id.work_location', string="Место трудоустройства")

在xml中

<field name="work_location"/>

当我卸载然后安装模块时没关系但是当我改变一些甚至在xml中并尝试更新模块时我有一个错误

Odoo Server Error
Traceback (most recent call last):
  File "/opt/odoo13/odoo/odoo/http.py", line 619, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo13/odoo/odoo/http.py", line 309, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/odoo13/odoo/odoo/tools/pycompat.py", line 14, in reraise
    raise value
  File "/opt/odoo13/odoo/odoo/http.py", line 664, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo13/odoo/odoo/http.py", line 345, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo13/odoo/odoo/service/model.py", line 93, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo13/odoo/odoo/http.py", line 338, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo13/odoo/odoo/http.py", line 909, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo13/odoo/odoo/http.py", line 510, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo13/odoo/addons/web/controllers/main.py", line 1323, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/opt/odoo13/odoo/addons/web/controllers/main.py", line 1311, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo13/odoo/odoo/api.py", line 395, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo13/odoo/odoo/api.py", line 382, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "<decorator-gen-64>", line 2, in button_immediate_upgrade
  File "/opt/odoo13/odoo/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
    return method(self, *args, **kwargs)
  File "/opt/odoo13/odoo/odoo/addons/base/models/ir_module.py", line 629, in button_immediate_upgrade
    return self._button_immediate_function(type(self).button_upgrade)
  File "/opt/odoo13/odoo/odoo/addons/base/models/ir_module.py", line 573, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)
  File "/opt/odoo13/odoo/odoo/modules/registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo13/odoo/odoo/modules/loading.py", line 416, in load_modules
    force, status, report, loaded_modules, update_module, models_to_check)
  File "/opt/odoo13/odoo/odoo/modules/loading.py", line 312, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/opt/odoo13/odoo/odoo/modules/loading.py", line 194, in load_module_graph
    registry.setup_models(cr)
  File "/opt/odoo13/odoo/odoo/modules/registry.py", line 247, in setup_models
    model._setup_fields()
  File "/opt/odoo13/odoo/odoo/models.py", line 2675, in _setup_fields
    field.setup_full(self)
  File "/opt/odoo13/odoo/odoo/fields.py", line 405, in setup_full
    self._setup_related_full(model)
  File "/opt/odoo13/odoo/odoo/fields.py", line 458, in _setup_related_full
    field = target._fields[name]
KeyError: 'work_location'

我不在其他任何地方使用 work_location。我无法理解我做错了什么。(抱歉英语不好)

4

1 回答 1

1

It seems use of dependency module is missing in your custom module manifest file. Make sure you have added hr module in it. Like

'depends': ['hr']
于 2020-02-11T07:57:38.430 回答