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

Changing the color of text based on the option selected in fields.selection field in Odoo class

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
selectionfontsodoofields.selection
3 Replies
12776 Rodiniai
Portretas
Omar Rasheed

Hello everyone,I hope all of you are fine.I have  one question,the question is that suppose I have a field of type selection in my class model.Suppose following is the field :


q_test = fields.Selection ( selection = [( 'n' , 'Normal' ), ( 'abn' , 'Abnormal' )], string = 'my field' )

Now suppose I want that when the user selects Abnormal option from the selection field,the text displayed to the user on frontend should be red,and if the user selects the option Normal,then it should be displayed as normal (i.e Black color font).

How can I achieve this,should I use some widget for it or is their any builtin option available in Odoo that can help me perform this task.

Thank you in advance.

0
Portretas
Atmesti
Portretas
Husain Rangwala
Best Answer

Hello Omar
You can apply one trick to show different color for selection field.

<field name="gender" string="Gender" style="color: red;" attrs="{'invisible': ['|',('gender','=','female'),('gender', '=', False)]}"/>
<field name="gender" string="Gender" style="color: green;" attrs="{'invisible': ['|',('gender','=','male'),('gender', '=', False)]}"/>
<field name="gender" string="Gender"  attrs="{'invisible': ['|',('gender','=','male'),('gender','=','female')]}"/>

Thanks.
1
Portretas
Atmesti
Portretas
Honey Patel (hop)
Best Answer

Hello Omar,

Might this work for you

Add decoration in view

0
Portretas
Atmesti
Honey Patel (hop)

<field name="q_test" decoration-danger="q_test == 'abn'" />

Portretas
Omar Rasheed
Autorius Best Answer

This is not working in my case,and also even if it works,then dont you think its not that good an approach because its quite static,hard coded,as you can see that in this example we have just 2 values,suppose when we have more than 2 values,like 10,15 values and I want to give different colors to them

For example the field is country=fields.Selection() and in that field we have 30 countries,so I will have to give different color to all the fields by writing <field='country'.....> 30 times.So is their any better and dynamic solution for this kind of problem like using some widgets or javascript code by which we get the value of selection field when user enters the data like ,document.getElementById('xyz').fontcolor='blue' ,something like this?Any such solution?Does that exist?Suggestion on this problem will be highly appreciated.

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
Add value to selection field without coding
selection odoo
Portretas
Portretas
Portretas
3
gruod. 19
5063
how to count on selection value
selection count odoo
Portretas
Portretas
Portretas
2
spal. 24
2036
How do I get the value of a selection field - widget=radio ?
selection odoo odoo12
Portretas
0
bal. 22
5260
How to add new value in Selection in Settings Solved
settings selection odoo
Portretas
Portretas
1
geg. 21
4627
Odoo Selection field issue Solved
selection odoo odoo12 odoo12.0
Portretas
Portretas
Portretas
Portretas
3
kov. 24
8049
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