Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Display field when the change of many2one field

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
3 Antwoorden
14643 Weergaven
Avatar
Remya

I have one many2one field. Many2one field is country_id(res.country).

When i select India in the many2one field, two char field should be displayed. otherwise fields should be hidden.

When select another country from the many2one field another two char field should be displayed?

how i can do this?

3
Avatar
Annuleer
Avatar
Prakash
Beste antwoord

The below code When you select India in the many2one field, two char field should be display. Python Code:-

_columns = {        
    'country_id': fields.many2one('res.country', 'Country'),
    'country_name': fields.related('country_id', 'name', type="char", relation="res.country", string="Name"),
        'field1_name': fields.char('Field1', size=64),  
        'field2_name': fields.char('Field2', size=64),  
    }

def onchange_country(self, cr, uid, ids, country_id, context=None):
value = {}
res_country = self.pool.get('res.country')        
if country_id:           
    value = {
      'country_name': res_country.browse(cr, uid, country_id).name
    }
return {'value': value}

XML code:-

<field name="country_id" on_change="onchange_country(country_id)"/> 
<field name="country_name" invisible="1"/> 
<field name="field1_name" attrs="{'invisible':[('country_name', '!=', 'India')]}"/>
<field name="field2_name" attrs="{'invisible':[('country_name', '!=', 'India')]}"/>
3
Avatar
Annuleer
Remya
Auteur

Thank you very much,Prakash. I just ask you a doubt. If i directly give country_id=23 for india will it work.ie, attrs="{'invisible':[('country_id', '!=', 23)]}"

Prakash

Yes it will works. But country_id hard coded. For Example in my DB Country ID for India is stored 105. so need to change code ID based on DB. The above code will works in any DB.

Remya
Auteur

But i give the above attr line, its not working.

Prakash

Have u used the same code?.. on_change function and invisible country_name in the form view.

Remya
Auteur

sorry, not your code Prakash. I just simply created a field with <field name="field1_name" attrs="{'invisible':[('country_id', '!=', '2')]}"/> , but its not working. will it not work without python code?

Prakash

Remove the symbol ' ' and apply <field name="field1_name" attrs="{'invisible':[('country_id', '!=', 2)]}"/> And to check ID using select id from res_company where name="India' and apply the ID in xml file.

Remya
Auteur

Hi Prakash, I'm asking another doubt: I want to display first login time in my attendance custom report. Did you know the code? One employee will login more than one time a day, but i want the first login time. http://help.openerp.com/question/48949/generating-a-custom-report-for-employees-login-time/ Can you please help me?

Avatar
Serge
Beste antwoord

You only need a conditition like that, that will hide field if country is not india

<field name="your_field_name_india" attrs="{'invisible':[('country_id', '!=', ref('base.in'))]}"/>
<field name="your_field_name" attrs="{'invisible':[('country_id', '=', ref('base.in'))]}"/>

*base.id is the XML_ID for the country INDIA

1
Avatar
Annuleer
Avatar
silvi
Beste antwoord

create a hidden related field to many2one . based on that hidden field change the attrs::invisible on the fields that you want to display at runtime.

0
Avatar
Annuleer
Remya
Auteur

I didn't get. I already have a many2one field that is not hidden. I already tried attrs:invisible, but it is not working. i think my code is wrong. can you please wrote the condition here.

silvi

attrs="{'invisible':[(field , '=', 'india')]}"

Remya
Auteur

But its not hiding.

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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