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

Put the name of a select field in a qweb report

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
qwebreportodoo
3 Cevaplar
6337 Görünümler
Avatar
Learning_Odoo
judgements = fields.Selection(
[
('family_lawsuits', 'Juicios Familiares')])

I have this selector that is stored inside a one2many, when I command to call the field in the qweb and print it, I want it to print the option that says "Family Lawsuits", but it prints the first option that is "family_lawsuits", how can I do to print the second option?
I already tried putting a .name at the end of the field, but it gives me the following error: AttributeError: 'str' object has no attribute 'name'


0
Avatar
Vazgeç
Avatar
Kiran K
En İyi Yanıt

Hi,

Try,

<t t-esc="dict(object.fields_get(allfields=['your_selection_field'])['your_selection_field']['selection'])[object.your_selection_field]"/>


1
Avatar
Vazgeç
Avatar
Gracious Joseph
En İyi Yanıt

In Odoo QWeb reports, when working with Selection fields, the value stored in the database (e.g., family_lawsuits) is returned by default. If you want to display the human-readable label (e.g., Juicios Familiares), you need to use the dict() function to map the selection field value to its label.

Here’s how you can print the label of a selection field in a QWeb report:

1. Add a Helper Method in the Model

To make the selection field's label accessible in your QWeb report, add a helper method in your model.

Example:

class YourModel(models.Model):
    _name = 'your.model'

    judgements = fields.Selection(
        [('family_lawsuits', 'Juicios Familiares')],
        string="Judgements"
    )

    def get_judgement_label(self, value):
        """
        Returns the human-readable label for the judgements selection field.
        """
        selection_dict = dict(self.fields_get()['judgements']['selection'])
        return selection_dict.get(value, '')

2. Use the Helper Method in QWeb

In your QWeb template, you can now call this helper method to fetch and display the human-readable label.

Example QWeb Template:

<t t-foreach="doc.one2many_field_ids" t-as="line">
    <tr>
        <td>
            <!-- Call the helper method to get the label -->
            <t t-esc="line.get_judgement_label(line.judgements)"/>
        </td>
    </tr>
</t>

3. Directly Map Selection Field in QWeb (Without a Helper)

If you don’t want to define a helper method, you can directly use the dict() function in your QWeb report. However, this approach is less reusable.

Example:

<t t-foreach="doc.one2many_field_ids" t-as="line">
    <tr>
        <td>
            <!-- Map the selection value to its label -->
            <t t-esc="dict(line.fields_get()['judgements']['selection'])[line.judgements]"/>
        </td>
    </tr>
</t>

Note: This direct method works, but if you have many fields to convert or if you need to reuse the logic elsewhere, the helper method is better.

4. If the Selection Field Is in a Related Model

If the judgements field is in a related model (e.g., a one2many), you must use the dict() function or helper method on the related record.

Example for Related Models:

<t t-foreach="doc.one2many_field_ids" t-as="line">
    <tr>
        <td>
            <t t-esc="dict(line.fields_get()['judgements']['selection'])[line.judgements]"/>
        </td>
    </tr>
</t>

5. Final Debugging Tips

  • Ensure the selection field is accessible in the record you are iterating over.
  • Use t-esc to evaluate Python expressions in QWeb safely.
  • Use t-debug to inspect values in the report during development.
<t t-debug="line.judgements"/>

By following this approach, you’ll be able to display the human-readable label (Juicios Familiares) of the selection field in your QWeb report. Let me know if you need further assistance!

0
Avatar
Vazgeç
Avatar
Andres Panoso
En İyi Yanıt

You can user the following: 

map_report_type = dict(self._fields["report_type"].selection)


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
Expect singleton: res.currency[SOLVED] Çözüldü
qweb report odoo
Avatar
Avatar
Avatar
2
Haz 23
5689
Pass result from SQL Query to Qweb Report
qweb report odoo
Avatar
0
Mar 22
3128
How to groups the same value name on QWEB Report Odoo ??
qweb report odoo
Avatar
0
Ağu 21
5904
How To pass data to report action ?
qweb report odoo
Avatar
0
Nis 18
9494
How to customize qweb report ? Çözüldü
qweb report odoo
Avatar
1
Ara 17
8803
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