1

I want to migrate my custom module to Odoo 15 code. But I get this kind of error all the time. I cant find a solution. The xml is in my data folder directed like this : custom_modul/data/mail_activity_types.xml. If you see any sytax errors it because I had to change the code a bit because of sensitive information. This code is Odoo 13 code and its working on it fine.

<?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>
for-loop
  • 47
  • 1
  • 8

2 Answers2

2

The res_model_id field was converted to selection and renamed to res_model.

The following code:

<field name="res_model_id" ref="crm.model_crm_lead"/>

Should be written as follows:

<field name="res_model">crm.lead</field>

The changes are detailed in [FIX] mail: convert res_model_id to selection commit:

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.

Kenly
  • 24,317
  • 7
  • 44
  • 60
  • Thank you very much. I would like to tick your answer as correct but CZoellner was faster and I only can tick one at same time – for-loop Jan 10 '22 at 12:57
  • 1
    The fields [force_next](https://github.com/odoo/odoo/commit/8aa1d6ff02b6e86c6ff4dbe552e9ae60453fce89#diff-2aea01ab5f00d4e08afe63c6cfbfcfd3314d90e367f8992df5492a7ba0478c96L96) from `mail.activity.type` and its related field from `mail.activity` are removed. Instead, a new field `chaining_type`, which is a `selection` will improve the readability of the activity_type form – Kenly Jan 10 '22 at 19:45
1

The field res_model_id is not existing anymore on model mail.activity.type. You probably should set res_model instead, which is a selection field, but the selection keys are model names (technical names). So for example creating a new type by xml should look like:

<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>
CZoellner
  • 13,553
  • 3
  • 25
  • 38
  • Thank you very much. But now also this tag is wrong : `1` line 6 – for-loop Jan 10 '22 at 08:18
  • 1
    You should probably look into the model [here](https://github.com/odoo/odoo/blob/04f01c58849cd556479d6d63bcf7365f51fa2f20/addons/mail/models/mail_activity_type.py). There is no `force_next` field on the model. Odoo probably changed how previous and following activities are managed. – CZoellner Jan 10 '22 at 08:22
  • 2
    Thanks this helped me a lot :). Instead of `1` it should be in Odoo 15 ` triggered ` – for-loop Jan 10 '22 at 12:59