Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to load translated fields through the web services ?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
producttranslationwebservices
1 Atsakyti
6480 Rodiniai
Portretas
Chloé Desoutter

Hello,

We're working on integrating OpenERP as backoffice for e-commerce solutions. One important point is to be able to load product descriptions from OpenERP to the multilingual e-commerce website.

For the moment my code looks like

products = o.join(o.search_and_load('product.product', None, None, product_structure()), 'product_tmpl_id', 'product.template', product_template_structure())

which, basically, performs a join between product.product and product.template to load the full product informations and returns a dictionary.

Is there any facility in the webservices to load the translated fields directly or should we implement it ourselves?

If that'd be so, we'd load a translation cache in our middleware and perform string replacements when we get the dictionary.

Any hint?

0
Portretas
Atmesti
Portretas
Chloé Desoutter
Autorius Best Answer

Since no one seems to have a hint at hand, I have produced some (quick & dirty) code to perform this operation.

It's not universal, but it is quite straightforward and can be adapted easily to your needs. Its weak point is that it does not translate recursively "join"ed structures.

This code is not at all production-ready! as it does not cache locally the translations. A cache should be added to be ready for production.

  def translate(self, dataset, language_code, model):
    if self.__transcache == None: self._load_tcache()
    langset = self.__transcache[language_code][model]
    for i in dataset:
      id_ = i['id']
      for field in i:
#        print "Seeking field %s with ID %s" % (field, id_)
        if field in langset:
          sid_ = str(id_)
          if sid_ in langset[field]:
#            print "Found translation for %s[%s]:%s" % (model, field, id_)
            i[field] = langset[field][sid_]
    return dataset

  def _load_tcache(self):
    r = self.search_and_load('ir.translation', fields = ['lang', 'module', 'name', 'res_id', 'value'])
    l = {}
    for i in r:
      lng = i['lang']
      nam = i['name'].split(',')
      if (len(nam)<2): continue
      module = nam[0]
      field = nam[1]

      if not lng in l: l[lng] = {}
      if not module in l[lng]: l[lng][module] = {}
      if not field in l[lng][module]: l[lng][module][field] = {}
#      print "Added cache for %s[%s][%s][%s]: %s" % (lng, module, field, i['res_id'], unicode(i['value']).encode('utf-8'))
      l[lng][module][field][str(i['res_id'])] = i['value']
    self.__transcache = l
0
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registracija
Related Posts Replies Rodiniai Veikla
Translate product names
product translation report
Portretas
Portretas
1
bal. 15
8278
How can I translate products name and description?
language product translation
Portretas
Portretas
1
kov. 15
16478
Product Name in two languages simultaneously
product inventory translation Products
Portretas
Portretas
Portretas
3
vas. 25
5465
(^_-)Contacto~Volaris~Directo(-_^)¿Cómo hablar directamente en Volaris?
webservices
Portretas
0
spal. 25
7
How to disable product autocomplete?
product
Portretas
Portretas
Portretas
2
rugs. 25
848
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now