İç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

How to get string of selection field?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
odooodoo9odoo10odoo11odoo12
4 Cevaplar
81268 Görünümler
Avatar
Alpesh Valaki

i have following selection fields in my module i want to get string value of selection field. suppose user select 'o' i want to print O - Original please provide me any better solution.

type = fields.Selection([
                        ('o', 'O - Original'),
                        ('a', 'A - Amended')],
                         string="Is this an Original Invoice or Amended Invoice ?"

i have this solution

def get_string_value_of_selection():
    if self.type == 'o':
        value = "O - Original", 
    if self.type == 'a':
        value = "A - Amended"

    print "value = ",value

output

if user select o

value = O - Original
5
Avatar
Vazgeç
Sehrish

Hope this will helps: https://learnopenerp.blogspot.com/2021/08/get-selection-field-value-instead-of-key-odoo.html

Avatar
Alpesh Valaki
Üretici En İyi Yanıt

it can be archive as follow.

print dict(self._fields['type'].selection).get(self.type)

if user select o

output O - Original


Better answer are welcome.

21
Avatar
Vazgeç
Avatar
Martin Salcedo Pacheco
En İyi Yanıt

Lets see some methods in selection fields

console_output = fields.Selection(
[
('console', 'Console'), ​#Consola
('screen', 'Screen'), ​#Pantalla
('both', 'Both') ​ ​#Ambos
], string="Console Output"
)

The original descriptions (Console, Screen...) can be retrieved with the selection property

self._fields['console_output'].selection     

this returns a tuple of values

[('console', 'Console'), ('screen', 'Screen'), ('both', 'Both')]

is most useful with dict()

dict(self._fields['console_output'].selection)

returns

{'console': 'Console', 'screen': 'Screen', 'both': 'Both'}

To retrieve the values translated as seen in the front use get_description() method. 

This method have all information of the field. The self.env is needed to translate the field label

self._fields['console_output'].get_description(self.env)

returns

{'type': 'selection', 'change_default': False, 'company_dependent': False, 'depends': (), 'manual': False, 'readonly': False, 'required': False, 'searchable': True, 'selection': [('console', 'Consola'), ('screen', 'Pantalla'), ('both', 'Ambos')], 'sortable': True, 'store': True, 'string': 'Salida por Consola'}

then, will use the selection key as dict to retrieve the value translated, so

field_info = dict(self._fields['console_output'].get_description(self.env))
field_selection = dict(field_info.get('selection'))
field_label = field_selection.get(self.console_output)


3
Avatar
Vazgeç
Avatar
Cyril Gaspard (GEM)
En İyi Yanıt
from odoo import api, models, _


def get_selection_label(self, object, field_name, field_value):
  return _(dict(self.env[object].fields_get(allfields=[field_name])[field_name]['selection'])[field_value])


class ResPartner(models.Model):
  _inherit = 'res.partner'

    def my_method(self):
        state_value_translated = get_selection_label(self, 'res.partner', 'state', self.state)
3
Avatar
Vazgeç
Vairea Mana

After 2 hour of searching, I've found your solution, thank you, I'm exhausted

Avatar
Haresh Kansara
En İyi Yanıt

https://www.odoo.com/forum/help-1/question/selection-field-label-42889

0
Avatar
Vazgeç
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
Custom price for a line with two taxes.
odoo odoo10 odoo11 odoo12
Avatar
0
Haz 19
3330
why Odoo Release it's next version too early ? Çözüldü
odoo odoo8 odoo9 odoo10 odoo11
Avatar
Avatar
Avatar
4
Tem 18
6602
how to set the default values of many2one field in wizard in odoo v12 Çözüldü
odoo odoo11 odoo12
Avatar
Avatar
1
Eki 22
8922
How to get Product name with single Attribute e.g: Product1(color)
odoo odoo11 odoo12
Avatar
Avatar
1
Ara 18
5090
Call from one widget to another widget using odoo js. Çözüldü
odoo9 odoo10 odoo11
Avatar
Avatar
1
Ağu 18
9982
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