如何修复升级odoo 13模块时的模型错误



我在尝试升级odoo 13中的自定义模块时遇到此错误。

Odoo Server Error
Traceback (most recent call last):
File "/odoo/odoo-server/odoo/http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/odoo/odoo-server/odoo/http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/odoo/odoo-server/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/odoo/odoo-server/odoo/http.py", line 664, in dispatch
result = self._call_function(**self.params)
File "/odoo/odoo-server/odoo/http.py", line 345, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/odoo/odoo-server/odoo/service/model.py", line 93, in wrapper
return f(dbname, *args, **kwargs)
File "/odoo/odoo-server/odoo/http.py", line 338, in checked_call
result = self.endpoint(*a, **kw)
File "/odoo/odoo-server/odoo/http.py", line 910, in __call__
return self.method(*args, **kw)
File "/odoo/odoo-server/odoo/http.py", line 510, in response_wrap
response = f(*args, **kw)
File "/odoo/odoo-server/addons/web/controllers/main.py", line 1324, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/odoo/odoo-server/addons/web/controllers/main.py", line 1312, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/odoo/odoo-server/odoo/api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/odoo/odoo-server/odoo/api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-64>", line 2, in button_immediate_upgrade
File "/odoo/odoo-server/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "/odoo/odoo-server/odoo/addons/base/models/ir_module.py", line 629, in button_immediate_upgrade
return self._button_immediate_function(type(self).button_upgrade)
File "/odoo/odoo-server/odoo/addons/base/models/ir_module.py", line 573, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/odoo/odoo-server/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/odoo/odoo-server/odoo/modules/loading.py", line 471, in load_modules
env['ir.model.data']._process_end(processed_modules)
File "/odoo/odoo-server/odoo/addons/base/models/ir_model.py", line 1971, in _process_end
record.unlink()
File "/odoo/odoo-server/odoo/addons/base/models/ir_model.py", line 1190, in unlink
table=self.env[selection.field_id.model]._table,
File "/opt/odoo/odoo13/odoo/api.py", line 463, in __getitem__
return self.registry[model_name]._browse(self, (), ())
File "/opt/odoo/odoo13/odoo/modules/registry.py", line 177, in __getitem__
return self.models[model_name]
KeyError: 'sales.terms'

这是sales.rms型号

class SalesTermsAndConditions(models.Model):
_name = 'sales.terms'
_description = 'Terms and Conditions'
_rec_name = 'typex'
new_type = fields.Selection([
('accessories', 'Accessories'),
('glass', 'Glass Work'),
('aluminium', 'Aluminium profiles'),
('projects', 'Projects')
], string='Testing')
d_active = fields.Boolean(string='Active')
notes = fields.Text()

我创建了一个名为"sales.terms"的新模型,并为其创建了相应的ir.model.access.csv文件,因此我追踪了错误,发现导致错误的不是整个模型,而是选择字段,如果我删除选择字段,模块升级会很好。

我对可能出了什么问题感到困惑。

我认为缺少

class SalesTermsAndConditions(models.Model):
_name = 'sales.terms'
_description = 'Terms and Conditions'
_rec_name = 'typex'
new_type = fields.Selection([
('test', 'Test'),
('atest', 'A test'), // Comma is missing
('accessories', 'Accessories'),
('glass', 'Glass Work'),
('aluminium', 'Aluminium profiles'),
('projects', 'Projects')
], string='Testing')
d_active = fields.Boolean(string='Active')
notes = fields.Text()

尝试删除_rec_name.Replace和一些字段。

_rec_name = "new_type"

选择似乎还可以。如果重命名new_type,它会升级吗?你能在启动odoo或重新加载模块时查看第一个错误吗

相关内容

  • 没有找到相关文章

最新更新