İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

ir_translation for create form

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
transactionsqlir_translationv14
2 Cevaplar
3510 Görünümler
Avatar
Denis Lutsak

I have made a code that gets the translation value of the name field from the database and allows you to edit it and change it in the database, this code is not very well written (because this is the first time I work directly with the database), but it works for all languages and for all cases when the form is already created, but I can't figure out how to add this code so that it works when creating a new form. I was thinking of making the nameUA, nameRU... fields not count during creation, but only during editing, but I haven't figured out how to do it.

Here are my fields:

name = fields.Char('Name', index=True, required=True, translate=True)
nameUA = fields.Char('Name Ua', default=name, compute='_compute_name_ukr', required=True, readonly=False)
nameRU = fields.Char('Name Ru', default=name, compute='_compute_name_rus', required=True, readonly=False)
nameDE = fields.Char('Name De', default=name, compute='_compute_name_deu', required=True, readonly=False)
nameEN = fields.Char('Name En', default=name, compute='_compute_name_eng', required=True, readonly=False)

Here is my implementation code:

def _compute_name_ukr(self):
for template in self:
template.env.cr.execute(
f"""SELECT src FROM ir_translation WHERE value = '{template.name}';""")
src = template.env.cr.fetchall()[0][0]
template.env.cr.execute(f"""SELECT value FROM ir_translation WHERE src = '{src}' and lang ='uk_UA';""")
name = template.env.cr.fetchall()[0][0]
if name == '':
template.env.cr.execute(
f"""SELECT value FROM ir_translation WHERE src = '{src}' and lang ='{template.env.user.lang}';""")
name = template.env.cr.fetchall()[0][0]
template.env.cr.execute(
f"""UPDATE ir_translation SET value ='{name}' WHERE src = '{template.nameEN}' and lang ='uk_UA';""")
template.nameUA = name

@api.onchange('nameUA')
def onchange_name_ukr(self):
for template in self:
template.env.cr.execute(f"""UPDATE ir_translation SET value ='{template.nameUA}' WHERE src = '{template.nameEN}' and lang ='uk_UA';""")

def _compute_name_deu(self):
for template in self:
template.env.cr.execute(
f"""SELECT src FROM ir_translation WHERE value = '{template.name}';""")
src = template.env.cr.fetchall()[0][0]
template.env.cr.execute(f"""SELECT value FROM ir_translation WHERE src = '{src}' and lang ='de_DE';""")
name = template.env.cr.fetchall()[0][0]
if name == '':
template.env.cr.execute(
f"""SELECT value FROM ir_translation WHERE src = '{src}' and lang ='{template.env.user.lang}';""")
name = template.env.cr.fetchall()[0][0]
template.env.cr.execute(
f"""UPDATE ir_translation SET value ='{name}' WHERE src = '{src}' and lang ='de_DE';""")
template.nameDE = name

@api.onchange('nameDE')
def onchange_name_deu(self):
for template in self:
template.env.cr.execute(f"""UPDATE ir_translation SET value ='{template.nameDE}' WHERE src = '{template.nameEN}' and lang ='de_DE';""")

def _compute_name_rus(self):
for template in self:
template.env.cr.execute(
f"""SELECT src FROM ir_translation WHERE value = '{template.name}';""")
src = template.env.cr.fetchall()[0][0]
template.env.cr.execute(f"""SELECT value FROM ir_translation WHERE src = '{src}' and lang ='ru_RU';""")
name = template.env.cr.fetchall()[0][0]
if name == '':
template.env.cr.execute(
f"""SELECT value FROM ir_translation WHERE src = '{src}' and lang ='{template.env.user.lang}';""")
name = template.env.cr.fetchall()[0][0]
template.env.cr.execute(
f"""UPDATE ir_translation SET value ='{name}' WHERE src = '{src}' and lang ='ru_RU';""")
template.nameRU = name

@api.onchange('nameRU')
def onchange_name_rus(self):
for template in self:
template.env.cr.execute(f"""UPDATE ir_translation SET value ='{template.nameRU}' WHERE src = '{template.nameEN}' and lang ='ru_RU';""")
def _compute_name_eng(self):
for template in self:
template.env.cr.execute(
f"""SELECT src FROM ir_translation WHERE value = '{template.nameRU}';""")
src = template.env.cr.fetchall()[0][0]
template.nameEN = src

@api.onchange('nameEN')
def onchange_name_eng(self):
for template in self:
template.env.cr.execute(
f"""SELECT src FROM ir_translation WHERE value = '{template.nameDE}';""")
src = template.env.cr.fetchall()[0][0]
template.env.cr.execute(
f"""UPDATE ir_translation
SET value ='
{template.nameEN}'
WHERE src = '
{src}' and lang ='en_US';
""")
template.env.cr.execute(
f"""UPDATE ir_translation
SET src ='
{template.nameEN}'
WHERE value ='
{template.nameEN}' and lang ='en_US';
""")
template.env.cr.execute(
f"""UPDATE ir_translation
SET src ='
{template.nameEN}'
WHERE value ='
{template.nameUA}' and lang ='uk_UA';
""")
template.env.cr.execute(
f"""UPDATE ir_translation
SET src ='
{template.nameEN}'
WHERE value ='
{template.nameRU}' and lang ='ru_RU';
""")
template.env.cr.execute(
f"""UPDATE ir_translation
SET src ='
{template.nameEN}'
WHERE value ='
{template.nameDE}' and lang ='de_DE';
""")

template.env.cr.execute(
f"""SELECT src FROM ir_translation WHERE value = '{template.nameRU}';""")
src = template.env.cr.fetchall()[0][0]
template.nameEN = src

@api.onchange('name')
def name_onchange(self):
for template in self:
if template.env.user.lang == 'de_DE':
template.nameDE = template.name
if template.env.user.lang == 'uk_UA':
template.nameUA = template.name
if template.env.user.lang == 'ru_RU':
template.nameRU = template.name
if template.env.user.lang == 'en_US':
template.nameEN = template.name

If anyone can give me a hint to solve my problem I will be most grateful!

0
Avatar
Vazgeç
Avatar
Ravi Gadhia
En İyi Yanıt

Odoo provides built-in support for adding a translation term for translated fields, what's your use case?





I think it's not a good idea to create compute fields for translation,  it would be better to create a new form/widget in js and handle the translation based on context like the translation dialog box did 
ref: https://github.com/odoo/odoo/blob/14.0/addons/web/static/src/js/widgets/translation_dialog.js#L10
https://github.com/odoo/odoo/blob/14.0/addons/web/static/src/js/widgets/translation_dialog.js#L166

0
Avatar
Vazgeç
Denis Lutsak
Üretici

I know that it can be done with translate=True, but I need to do it in the form, not in a separate window.

Avatar
Savya Sachin
En İyi Yanıt

Hi,

Instead didn’t you try the builtin feature of translation provider by odoo, you can add the field parameter translate=True,

Just redifine your field like this,

name = fields.Char('Name', index=True, required=True, translate=True)
 For the time being, remove the unnecessary onchange and custom fields.

Now, activate the developer mode, settings -> translations -> in the application terms view filter the terms by your module and search for the name field. You will see all the translations for the name field in different languages and can edit here so that odoo will handle the translation for this field based on the users language preference.

Thanks

0
Avatar
Vazgeç
Denis Lutsak
Üretici

I know that it can be done with translate=True, but I need to do it in the form, not in a separate window.

Enjoying the discussion? Don't just read, join in!

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

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
d
sql odoo v14
Avatar
0
Ağu 21
111
How to use self._cr.execute get my data? Çözüldü
python sql odoo11 v14
Avatar
Avatar
Avatar
Avatar
3
Ara 21
16805
Advanced orm, sql insert through select, how to?
transaction orm insert sql select
Avatar
Avatar
1
Mar 15
8338
Odoo14 alternative for Automated Translations through Gengo API module
v14
Avatar
Avatar
Avatar
Avatar
3
Eyl 25
3631
Odoo Community v14 Slow on High-End Servers, Fast on i5/i7 PCs
v14
Avatar
0
Ağu 25
1063
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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