콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
236 화면

Hello,


We're using json-rpc calls to send, retrieve and manipulate data in Odoo (v15).


One thing I can't seem to figure out is how to create and update translations.

When retrieving data, you can play with the "lang" field in the "context" object, but this doesn't work for a create or an update.


Does anyone have any suggestions on how to achieve this?


Kind regards,

Geert

아바타
취소
베스트 답변

Hii,

Use ir.translation Model Directly

here is example of json-rpc :


Here’s how to create or update a French translation for a product name:

{

  "jsonrpc": "2.0",

  "method": "call",

  "params": {

    "service": "object",

    "method": "execute_kw",

    "args": [

      "your_db",

      2,  // user ID

      "your_password",

      "ir.translation",

      "create",

      [{

        "name": "product.template,name",   // model and field

        "res_id": 123,                     // ID of the product

        "lang": "fr_FR",

        "type": "model",

        "value": "Nom traduit du produit",

        "state": "translated"

      }]

    ]

  },

  "id": 1

}

To update, search the translation first:


ids = models.execute_kw(db, uid, password,

    'ir.translation', 'search', [[

        ['name', '=', 'product.template,name'],

        ['res_id', '=', 123],

        ['lang', '=', 'fr_FR']

    ]])


if ids:

    models.execute_kw(db, uid, password,

        'ir.translation', 'write',

        [ids, {'value': 'Nouveau nom en français'}])


i hope this example is help full

아바타
취소
작성자

Thanks a lot!
That's exactly what I was looking for.

관련 게시물 답글 화면 활동
1
6월 25
226
0
6월 25
170
2
6월 25
260
2
6월 25
602
1
5월 25
98