Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Put the name of a select field in a qweb report

Odoberať

Get notified when there's activity on this post

This question has been flagged
qwebreportodoo
3 Replies
6401 Zobrazenia
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
Zrušiť
Avatar
Kiran K
Best Answer

Hi,

Try,

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


1
Avatar
Zrušiť
Avatar
Gracious Joseph
Best Answer

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
Zrušiť
Avatar
Andres Panoso
Best Answer

You can user the following: 

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


0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Expect singleton: res.currency[SOLVED] Solved
qweb report odoo
Avatar
Avatar
Avatar
2
jún 23
5748
Pass result from SQL Query to Qweb Report
qweb report odoo
Avatar
0
mar 22
3156
How to groups the same value name on QWEB Report Odoo ??
qweb report odoo
Avatar
0
aug 21
5935
How To pass data to report action ?
qweb report odoo
Avatar
0
apr 18
9520
How to customize qweb report ? Solved
qweb report odoo
Avatar
1
dec 17
8852
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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