Skip to Content
Menu
This question has been flagged
2 Replies
561 Views

Hi,

I successfully wrote the script that migrates our Odoo11 projects attachments to Odoo17, by using external API (unallowed link to Odoo docs)

Now I have to write a script, that will do some other data / field updating from Odoo11 to Odoo17.

I created test case according to docs above, that create a tag and then to update the same tag:

new_tag_id = models17.execute_kw(odoo17_db, uid17, odoo17_password, 'project.tags', 'create', [{
    'name': "Test",
    'display_name': "Test",
}])

models17.execute_kw(
    odoo17_db, uid17, odoo17_password,
    'project.tags', 'write',
    [[new_tag_id]],
    {'name': "Testing upd"}
)

It creates new Test tag, but I stuck at the error when updating:

;Error updating project 5644 tags: <Fault 1: 'Traceback (most recent call last):\n  File "/opt/odoo/odoo/odoo/addons/base/controllers/rpc.py", line 147, in xmlrpc_2\n    response = self._xmlrpc(service)\n               ^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/addons/base/controllers/rpc.py", line 127, in _xmlrpc\n    result = dispatch_rpc(service, method, params)\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/http.py", line 389, in dispatch_rpc\n    return dispatch(method, params)\n           ^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/service/model.py", line 37, in dispatch\n    res = execute_kw(db, uid, *params[3:])\n          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/service/model.py", line 59, in execute_kw\n    return execute(db, uid, obj, method, *args, **kw or {})\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/service/model.py", line 65, in execute\n    res = execute_cr(cr, uid, obj, method, *args, **kw)\n          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/service/model.py", line 50, in execute_cr\n    result = retrying(partial(odoo.api.call_kw, recs, method, args, kw), env)\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/service/model.py", line 133, in retrying\n    result = func()\n             ^^^^^^\n  File "/opt/odoo/odoo/odoo/api.py", line 468, in call_kw\n    result = _call_kw_multi(method, model, args, kwargs)\n
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "/opt/odoo/odoo/odoo/api.py", line 453, in _call_kw_multi\n    result = method(recs, *args, **kwargs)\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: BaseModel.write() got an unexpected keyword argument \'name\'\n'>

I tried different fields on project.project and project.tags, simple and related, checked that they are Read-only: false etc. yet no way - the same error. 

BTW: I have permissions to CRUD either project and project tags. I can do it by using external API. Actually I have almost all possible permissions.


What I am doing wrong, what else to check?
brgds & looking forward

Avatar
Discard
Best Answer

Hi Janeks,

Following the example on the Official documentation. You are almost there, keep it up!

You can see that your format needs a little bit of tweak near the list.

models17.execute_kw(

    odoo17_db, uid17, odoo17_password,

    'project.tags', 'write',

    [[new_tag_id]],

    {'name': "Testing upd"}  # this should be inside the list

)

Replace it with

models17.execute_kw(

    odoo17_db, uid17, odoo17_password,

    'project.tags', 'write',

    [[new_tag_id], {'name': "Testing upd"}] # I moved it up into the list

)

hope this helps

Avatar
Discard
Author Best Answer

Andry, you are great!

Thanks a lot!

Fixed.

While I had written a lot of different other language scripts / code, this is my second Python script, so I am a bit blind on such argument syntax details yet + AI recommendations, that directed my focus to wrong directions.

Avatar
Discard

Happy if it helps. Would you do me a favor to upvote or mark my answer as solved? Thanks.

Related Posts Replies Views Activity
6
Dec 23
45141
0
Feb 24
3364
1
Apr 18
3343
0
Oct 24
189
1
Jun 24
930