Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to hide Selection Field Options based on condition :

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
fieldsselectioninvisibleodooV11
5 Antworten
20397 Ansichten
Avatar
Chaanto

Class ExampleCode(models.Model) :

_name = 'example.code'

there is have a one event list

event_list = fields.Selection([
('commu', 'Community Event'),

('company', 'Company Event'),

('school'', 'School Event'),

('collage'', 'Collage Event'),

], string='Event Type')

there 4 set of option based on event_list :

position_company = fields.Selection([
                                                ('ceo', 'CEO'),
                                                ('manager', 'Manager'),
                                                ('employee', 'Employee'),
                                                ('other', 'Others')
                                                ], string='Position')

position_community = fields.Selection([
                                                ('leader', 'Leader'),
                                                ('vice', 'Vice Leader'),
                                                ('member', 'member'),
                                                ('speaker', 'Speaker'),
                                                ('other', 'Others')
                                                ], string='Position')

position_school = fields.Selection([
                                                ('head', 'Headmaster'),
                                                ('teacher', 'Teacher'),
                                                ('council', 'Student Council'),
                                                ('student', 'Student'),
                                                ('other', 'Others')
                                                ], string='Position')

position_collage = fields.Selection([
                                                ('rector', 'Rector'),
                                                ('lecture', 'Lecturer'),
                                                ('student', 'Collage Student),
                                                ('other', 'Others')
                                                ], string='Position')


so instead of making 4 set of them i wanna to put them all in one fields selection then it would be invisible based on event_list is that possible ? if possible can you show me how to do it ?


reason why i wanna do something like this because i dont wanna show 4 position on one tree view so i should make something like this if there is another alternative please tell me how to do this .


Thank you,

Best Regards

0
Avatar
Verwerfen
Avatar
Jake Robinson
Beste Antwort

As an alternative approach you can use a computed field that will have the correct selection, but still use the 4 sub selections to dynamically show the appropriate options:

from odoo import api, fields, models

COMPANY_SELECTION = [
('ceo', 'CEO'),
('manager', 'Manager'),
('employee', 'Employee'),
('other', 'Others')
]
COMMUNITY_SELECTION = [
('leader', 'Leader'),
('vice', 'Vice Leader'),
('member', 'member'),
('speaker', 'Speaker'),
('other', 'Others')
]
SCHOOL_SELECTION = [
('head', 'Headmaster'),
('teacher', 'Teacher'),
('council', 'Student Council'),
('student', 'Student'),
('other', 'Others')
]
COLLAGE_SELECTION = [
('rector', 'Rector'),
('lecture', 'Lecturer'),
('student', 'Collage Student'),
('other', 'Others')
]


class ExampleCode(models.Model):
_name = 'example.code'
event_list = fields.Selection(string='Event Type', selection=[
('company', 'Company Event'),
('commu', 'Community Event'),
('school', 'School Event'),
('collage', 'Collage Event')
])

position_company = fields.Selection(string='Company Position', selection=COMPANY_SELECTION)
position_community = fields.Selection(string='Company Position', selection=COMMUNITY_SELECTION)
position_school = fields.Selection(string='Company Position', selection=SCHOOL_SELECTION)
position_collage = fields.Selection(string='Company Position', selection=COLLAGE_SELECTION)
position = fields.Selection(string="Position", selection=COMPANY_SELECTION + COMMUNITY_SELECTION + SCHOOL_SELECTION + COLLAGE_SELECTION, compute='_compute_position', store=True)

@api.depends('position', 'position_company', 'position_community', 'position_school', 'position_collage')
def _compute_position(self):
for rec in self:
if rec.event_list == 'company':
rec.position = rec.position_company
elif rec.event_list == 'commu':
rec.position = rec.position_community
elif rec.event_list == 'school':
rec.position = rec.position_school
elif rec.event_list == 'collage':
rec.position = rec.position_collage
else:
                rec.position = False


1
Avatar
Verwerfen
Avatar
Ravi Gadhia
Beste Antwort

There is no way to filter value of selection field or even would not apply domain on it.
​
So the alternative is 
Instead of taking four selection field take one many2one field like
                                                                                                                                                                                                  
position_id = fields.Many2one('job.position')

in job.position take named as type as a selection field like [('community','Community'), ('company','Company'), ....]

now on change of event_list set domain on position_id like
return {'domain': {'position_id': [('type', '=', self.event_list)]}}
​

0
Avatar
Verwerfen
Chaanto
Autor

well i thinks is not a good way to solve this problem, because i must make the many2one to handle this things. and my system already full of selection field for this, so i must fix all of them if i using this way.

Ravi Gadhia

Ok, but my main concern about your approach is if you create four different selection field when you need position value in another part of business logic you have to check/select all the fields

Chaanto
Autor

thanks for you answer, i'm already found the alternative that can dynamically to change fields selection based on condition, it just need the 4 global variable and 1 selection field and return the domain for filtering the slection field without change to m2o

Vysakh B Thottarath

@Chaanto Please Share your Answer ..

Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
how can I make a one2many field a selection field in view Gelöst
fields selection
Avatar
Avatar
Avatar
3
Okt. 25
18257
how to hide a field if empty in view mode and view it in edit mode (odoo11)?
fields invisible
Avatar
0
Nov. 17
6277
How to pass values to a method that defines selection for multiple fields?
fields selection
Avatar
0
Apr. 15
4866
How To Change Field Value According To Selection Field Openerp?
fields selection
Avatar
Avatar
1
März 15
10321
Why in Selection Field Only Key is Store in Database Not the Value ? Gelöst
fields database selection
Avatar
Avatar
1
Dez. 24
2449
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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