Odoo 15 - ValueError: Invalid field 'res_model_id' on model 'mail.activity.type'
Odoo 15 - ValueError: Invalid field 'res_model_id' on model 'mail.activity.type'
我想将我的自定义模块迁移到 Odoo 15 代码。但是我总是遇到这种错误。我找不到解决办法。 xml 在我的数据文件夹中,如下所示:custom_modul/data/mail_activity_types.xml。如果您看到任何语法错误,那是因为由于敏感信息,我不得不稍微更改代码。这段代码是 Odoo 13 代码,它运行良好。
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
<record id="mail_activity" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="force_next">1</field>
<field name="default_description">Please renew Red-Hat-License!</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity_secure" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity_certificates" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
</odoo>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 680, in _tag_root
f(rec)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 583, in _tag_record
record = model._load_records([data], self.mode == 'update')
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4398, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4327, in _load_records_create
return self.create(values)
File "<decorator-gen-67>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_fields.py", line 613, in create
recs = super().create(vals_list)
File "<decorator-gen-13>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4020, in create
raise ValueError("Invalid field %r on model %r" % (key, self._name))
ValueError: Invalid field 'res_model_id' on model 'mail.activity.type'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/usr/lib/python3/dist-packages/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 916, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1339, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1327, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-74>", line 2, in button_immediate_install
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 483, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 600, in _button_immediate_function
registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 87, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 474, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 363, in load_marked_modules
loaded, processed = load_module_graph(
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 745, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 811, in convert_xml_import
obj.parse(doc.getroot())
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 731, in parse
self._tag_root(de)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 693, in _tag_root
raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /opt/Odoo/Custom_Addon/customer_instance_setup/data/mail_activity_types.xml:3, somewhere inside
<record id="mail_activity_red_hat" model="mail.activity.type">
<field name="name">Red Hat Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="force_next">1</field>
<field name="default_description">Please renew License!</field>
<field name="delay_count">0</field>
</record>
模型 mail.activity.type
上不再存在字段 res_model_id
。您可能应该改为设置 res_model
,这是一个选择字段,但选择键是型号名称(技术名称)。因此,例如通过 xml 创建一个新类型应该如下所示:
<record id="mail_activity_certificates" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model">my.model</field>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
res_model_id
字段已转换为选择并重命名为 res_model
。
以下代码:
<field name="res_model_id" ref="crm.model_crm_lead"/>
应该这样写:
<field name="res_model">crm.lead</field>
更改详见[FIX] mail: convert res_model_id to selection提交:
Following the removal of read access on ir.model
(#69120),
the mail.activity.type
model was not accessible to non-admin users due
to the res_model_id
many2one field.
Before this commit, a project user could not access the Activity Type
menu.
Convert it to a selection field with the selection values being
computed in sudo.
我想将我的自定义模块迁移到 Odoo 15 代码。但是我总是遇到这种错误。我找不到解决办法。 xml 在我的数据文件夹中,如下所示:custom_modul/data/mail_activity_types.xml。如果您看到任何语法错误,那是因为由于敏感信息,我不得不稍微更改代码。这段代码是 Odoo 13 代码,它运行良好。
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="0">
<record id="mail_activity" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="force_next">1</field>
<field name="default_description">Please renew Red-Hat-License!</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity_secure" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity_certificates" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
<record id="mail_activity" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
</odoo>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 680, in _tag_root
f(rec)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 583, in _tag_record
record = model._load_records([data], self.mode == 'update')
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4398, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4327, in _load_records_create
return self.create(values)
File "<decorator-gen-67>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_fields.py", line 613, in create
recs = super().create(vals_list)
File "<decorator-gen-13>", line 2, in create
File "/usr/lib/python3/dist-packages/odoo/api.py", line 413, in _model_create_multi
return create(self, arg)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4020, in create
raise ValueError("Invalid field %r on model %r" % (key, self._name))
ValueError: Invalid field 'res_model_id' on model 'mail.activity.type'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/usr/lib/python3/dist-packages/odoo/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 916, in __call__
return self.method(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 535, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1339, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1327, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-74>", line 2, in button_immediate_install
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 483, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 600, in _button_immediate_function
registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 87, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 474, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 363, in load_marked_modules
loaded, processed = load_module_graph(
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 745, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 811, in convert_xml_import
obj.parse(doc.getroot())
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 731, in parse
self._tag_root(de)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 693, in _tag_root
raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing /opt/Odoo/Custom_Addon/customer_instance_setup/data/mail_activity_types.xml:3, somewhere inside
<record id="mail_activity_red_hat" model="mail.activity.type">
<field name="name">Red Hat Expiration</field>
<field name="res_model_id" ref="setup.my_model"/>
<field name="icon">fa-tasks</field>
<field name="force_next">1</field>
<field name="default_description">Please renew License!</field>
<field name="delay_count">0</field>
</record>
模型 mail.activity.type
上不再存在字段 res_model_id
。您可能应该改为设置 res_model
,这是一个选择字段,但选择键是型号名称(技术名称)。因此,例如通过 xml 创建一个新类型应该如下所示:
<record id="mail_activity_certificates" model="mail.activity.type">
<field name="name">Expiration</field>
<field name="res_model">my.model</field>
<field name="icon">fa-tasks</field>
<field name="delay_count">0</field>
</record>
res_model_id
字段已转换为选择并重命名为 res_model
。
以下代码:
<field name="res_model_id" ref="crm.model_crm_lead"/>
应该这样写:
<field name="res_model">crm.lead</field>
更改详见[FIX] mail: convert res_model_id to selection提交:
Following the removal of read access on
ir.model
(#69120),
themail.activity.type
model was not accessible to non-admin users due
to theres_model_id
many2one field.
Before this commit, a project user could not access the Activity Type menu.
Convert it to a selection field with the selection values being computed in sudo.