Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
6710 Lượt xem

Hello everybody (this is my first post),

I use a API client to request a Odoo (version 9e) instance. When I fetch one specific product I want to have its name in all different languages set in the instance (actually French and Spanish). 

I can only have it in French which is my main language. I tried to use a user/password which is language is set in Spanish but I get always the French version. How can I fetch this product name in Spanish ?

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

fetch all active langs and copy the context re-run your products queries by setting the context language over loop. that should get you what you need.


def get_translated_path(self, cr, uid, path, lang, context=None):
if lang == request.lang:
return path

ctx = context.copy()
ctx.update({'lang': request.lang})
view = self.pool.get('ir.ui.view')
view_ids = view.search(cr, uid, [('active', '!=', False)], context=context)
for obj in view.browse(cr, uid, view_ids, context=ctx):
if obj.name == path:
ctx.update({'lang': lang})
return view.browse(cr, uid, obj.id, context=ctx).name
return path
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Nobody ??

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 25
298
1
thg 8 25
585
2
thg 7 25
3043
3
thg 7 25
747
1
thg 6 25
2255