Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Related selection field or parent child drop down menus in odoo 14

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
pythonxmlmany2onerelateddomain_filter
2 Besvarelser
4458 Visninger
Avatar
jomin joseph

Hi guys i am using odoo 14, i have created a custom module that inherit into odoo, i want to create a selection field which i related to another field for eg: i have a selection field: A it has 3 options 1,2,3 if i select option 1 , it should show another selection field which should come only if i select 1 , if i select 2 it should show another selection field , is there any way i can achieve this using python or xml in odoo

0
Avatar
Kassér
Avatar
ss
Bedste svar

Hi, @jo
In Python
, Define all the SELECTION FIELDS that is required feature, that is the selection field with value 1 2 3 and selection field that will show for option 1 and selection field to show for option 2.

selection = fields.Selection([('1', '1'), ('2', '2'), ('3', '3')])
slection_for_opt_1 = fields.Selection([('5', '5'), ('6', '6')])
slection_for_opt_2 = fields.Selection([('7', '7'), ('8', '8')])

In XML, Add attrs attribute for the field defination on view as mentioned below

field name="selection"
field name="slection_for_opt_1" attrs="{'invisible': [('selection', '!=', '1')]}"
field name="slection_for_opt_2" attrs="{'invisible': [('selection', '!=', '2')]}"

1
Avatar
Kassér
jomin joseph
Forfatter

Hi @Sujata Bhuyan, i tried the code you shared but i am getting this error ValueError: dictionary update sequence element #0 has length 3; 2 is required

ss

Hi @jo, Can you share your code here. So that I can help.

jomin joseph
Forfatter

python side

# -*- coding: utf-8 -*-

from odoo import models, fields, api

class FieldsCustomDropDown(models.Model):
_inherit = 'sale.order'

selection = fields.Selection([('1', '1'), ('2', '2'), ('3', '3')])
slection_for_opt_1 = fields.Selection([('5', '6', '7')])
slection_for_opt_2 = fields.Selection([('8', '9', '10')])
slection_for_opt_3 = fields.Selection([('11', '12', '13')])
xml side

<record id="new_test_add_custom_purchase_fields_parameters_inherit" model="ir.ui.view">
<field name="name">purchase.test.add..new.custom.fields.inherited</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='category']"
position="after">
<field name="item"/>
</xpath>
</field>
</record>
actual selection will be around 10 options this for testing purpose i did but its not working

Avatar
Jainesh Shah(Aktiv Software)
Bedste svar

Hi Jo, 

Please find code in comment. 

I hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Kassér
Jainesh Shah(Aktiv Software)

Code :-

XML:
<field name="selection"/>
<field name="slection_for_opt_1" attrs="{'invisible': [('selection', '!=', '1')]}"/>
<field name="slection_for_opt_2" attrs="{'invisible': [('selection', '!=', '2')]}"/>
PY:
selection = fields.Selection([('1', '1'), ('2', '2'), ('3', '3')], string="Selection")
slection_for_opt_1 = fields.Selection([('5', '5'), ('6', '6'), ('7', '7')], string="Selection_1")
slection_for_opt_2 = fields.Selection([('8', '8'), ('9', '9'), ('10', '10')], string="Selection_2")

jomin joseph
Forfatter

this worked perfectly, i made an error in python side that's why it was not reflecting, thank you sir

Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
What should the view inherit from?
python xml view many2one
Avatar
0
mar. 15
5122
OpenERP 7 many2one with current month filter
filter python xml many2one
Avatar
Avatar
2
mar. 15
30216
openerp 7 .netsvc: Unable to use a closed cursor.
python xml many2one __openerp__.py
Avatar
0
mar. 15
7095
How to hide view.xml fields group in Account module with attr
python xml
Avatar
Avatar
Avatar
2
dec. 23
13862
how to remove first empty element from fields.selection Løst
python xml
Avatar
Avatar
Avatar
3
jul. 22
24286
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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