Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
5092 Näkymät

I have created an extra field in res.partner in Odoo 12 CE. I have made 2 custom modules which can inherit this field [registration = fields.Char(related='partner_id.registration')]. This works fine in the first module. However, in the second module, even though I can see the field has been created (in the list of fields from the Model in the Technical Menu), one I try adding the field to the views, it gives me the following error: 

File "/home/ubuntu/odoo/odoo/fields.py", line 527, in _setup_related_full
    field = target._fields[name]
KeyError: 'registration'

Full error is below:

Traceback (most recent call last): 
File "/home/ubuntu/odoo/odoo/http.py", line 656, in _handle_exception 
return super(JsonRequest, self)._handle_exception(exception) 
File "/home/ubuntu/odoo/odoo/http.py", line 314, in _handle_exception 
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) 
File "/home/ubuntu/odoo/odoo/tools/pycompat.py", line 87, in reraise 
raise value 
File "/home/ubuntu/odoo/odoo/http.py", line 698, in dispatch 
result = self._call_function(**self.params) 
File "/home/ubuntu/odoo/odoo/http.py", line 346, in _call_function 
return checked_call(self.db, *args, **kwargs) 
File "/home/ubuntu/odoo/odoo/service/model.py", line 97, in wrapper 
return f(dbname, *args, **kwargs) 
File "/home/ubuntu/odoo/odoo/http.py", line 339, in checked_call 
result = self.endpoint(*a, **kw) 
File "/home/ubuntu/odoo/odoo/http.py", line 941, in __call__ 
return self.method(*args, **kw) 
File "/home/ubuntu/odoo/odoo/http.py", line 519, in response_wrap 
response = f(*args, **kw) 
File "/home/ubuntu/odoo/addons/web/controllers/main.py", line 966, in call_button 
action = self._call_kw(model, method, args, {}) 
File "/home/ubuntu/odoo/addons/web/controllers/main.py", line 954, in _call_kw 
return call_kw(request.env[model], method, args, kwargs) 
File "/home/ubuntu/odoo/odoo/api.py", line 749, in call_kw 
return _call_kw_multi(method, model, args, kwargs) 
File "/home/ubuntu/odoo/odoo/api.py", line 736, in _call_kw_multi 
result = method(recs, *args, **kwargs) 
File "<decorator-gen-67>", line 2, in button_immediate_upgrade 
File "/home/ubuntu/odoo/odoo/addons/base/models/ir_module.py", line 74, in check_and_log 
return method(self, *args, **kwargs) 
File "/home/ubuntu/odoo/odoo/addons/base/models/ir_module.py", line 622, in button_immediate_upgrade 
return self._button_immediate_function(type(self).button_upgrade) 
File "/home/ubuntu/odoo/odoo/addons/base/models/ir_module.py", line 561, in _button_immediate_function 
modules.registry.Registry.new(self._cr.dbname, update_module=True) 
File "/home/ubuntu/odoo/odoo/modules/registry.py", line 86, in new 
odoo.modules.load_modules(registry._db, force_demo, status, update_module) 
File "/home/ubuntu/odoo/odoo/modules/loading.py", line 417, in load_modules 
force, status, report, loaded_modules, update_module, models_to_check) 
File "/home/ubuntu/odoo/odoo/modules/loading.py", line 313, in load_marked_modules 
perform_checks=perform_checks, models_to_check=models_to_check 
File "/home/ubuntu/odoo/odoo/modules/loading.py", line 194, in load_module_graph 
registry.setup_models(cr) 
File "/home/ubuntu/odoo/odoo/modules/registry.py", line 267, in setup_models 
model._setup_fields() 
File "/home/ubuntu/odoo/odoo/models.py", line 2609, in _setup_fields 
field.setup_full(self) 
File "/home/ubuntu/odoo/odoo/fields.py", line 484, in setup_full 
self._setup_related_full(model) 
File "/home/ubuntu/odoo/odoo/fields.py", line 527, in _setup_related_full 
field = target._fields[name] 
KeyError: 'registration'


Avatar
Hylkää
Paras vastaus

Hi,

Make sure you have given the dependencies correctly and if everything is fine try to upgrade via CLI

Avatar
Hylkää
Paras vastaus

That worked fine. Thanks

Avatar
Hylkää