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
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • 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

Working with fields.selection values

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
selection
1 Atsakyti
28334 Rodiniai
Portretas
Leopoldo Cantillo M.

Hi,

How I can read or return the value chosen from a selection field? I need the user to select values from a list, and use the selected value to complete the information in other fields in the form.

Thanks.

Some code used to test, with error:

....
 'seq_choosed': fields.selection([(11,'Product End'),(12,'Product Base')],'Sequence to use '),
...
 lot_sequence = self.pool.get('ir.sequence').get_id(cr, uid, seq_choosed.value, context={} )
1
Portretas
Atmesti
Sehrish

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

Portretas
Olivier Dony (odo)
Best Answer

Your question does not clearly explain what you want to do nor what you tried. You say you have an error but you do not say what is the error message (and trace). Your code example is not complete enough to understand properly.

Still, here are a few pointers:

  • How to obtain the value chosen by the user depends on where you do it: in an on_change method, in a fields.function, when overriding one of the base ORM methods, etc.
  • Have a look at the OpenERP Technical memento, it contains examples for these various use cases.
  • The selection field in your example has 2 possible hardcoded integer values: 11 or 12. This is rather unusual but supported. Most selection fields use string values though. In this case when you read() or browse() a record from the model in which this field is defined, you will get the value as an int (11 or 12) or False if the field was left empty (if it's not required).

Here's a random example based on the little information you provided:

Imagine you put an on_change on your field in the XML view:

  <field name="seq_choosed" on_change="on_change_seq_choosed(seq_choosed)"/>
  <field name="seq_num"/>

Then you could do something like the following:

  def on_change_seq_choosed(self, cr, uid, ids, seq_choosed, context=None):
       # on_change returns a dict
       result = {
           'value': {}
       }
       # selected value is explicitly passed in seq_choosed parameter in XML def 
       if seq_choosed:
           seq_num = self.pool.get('ir.sequence').get_id(cr, uid, seq_choosed, context=context)
           result['value']['seq_num'] = seq_num
       return result

That's not a very useful example, but if you want better answers you'll have to be a lot more specific in your question ;-)

2
Portretas
Atmesti
Leopoldo Cantillo M.
Autorius

Thanks a lot for your answer, and all the corrections, my English is no very good. I going to try this, and looking more about the on_change method.

Atchuthan - Technical Consultant, Sodexis Inc

@Oliver Dony, for instance I want to print the value (Product Base) with key (12), how to do?

If I print seq_choosed, it prints me the key of selection field. I need to print value of key chosen

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
how to add values dynamically in selection fields? Solved
selection
Portretas
Portretas
Portretas
Portretas
Portretas
4
gruod. 23
23249
Dynamically change choices in selection fields Solved
selection
Portretas
Portretas
Portretas
Portretas
Portretas
5
liep. 24
16618
How to change the values for a selection field? Solved
selection
Portretas
Portretas
Portretas
Portretas
Portretas
9
geg. 22
54631
How to get values from a radio button in a Selection
selection
Portretas
0
liep. 20
3736
Changing field selection data on change event
selection
Portretas
0
kov. 20
4458
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