Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Hide some possible choices in a Many2one field

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
many2onev14
2 Réponses
3569 Vues
Avatar
Raib

Hi, I've created a custom module which represents something similar to a school, with three models that represent teachers, courses and classes (course = literature, class = literature 2020-21 in 9th grade). 

DOCENTE.PY (docente=teacher) -> _name = 'piani_formazione.docente'
CORSO.PY (corso=course) -> _name = 'piani_formazione.corso'
EDIZIONE.PY (edizione=class) -> _name = 'piani_formazione.edizione'

Obviously, every course has multiple classes meanwhile every class is related to a specific course

CORSO.PY (corso=course) -> edizioni_corso = fields.One2many('piani_formazione.edizione', 'edizione_corso', string="Edizioni del corso erogate:")  
EDIZIONE.PY (edizione=class) -> edizione_corso = fields.Many2one('piani_formazione.corso', string="Edizione del corso:", required=True)

I've managed to state that every teacher is qualified to teach some courses (and viceversa that every course can be teached by some teachers)

DOCENTE.PY (docente=teacher) -> abilitazioni = fields.Many2many('piani_formazione.corso', 'tabella_docenti_corsi', 'codice_fiscale', 'codice', string="Corsi che è abilitato ad erogare:")    
CORSO.PY (corso=course) -> docenti_corso = fields.Many2many('piani_formazione.docente', 'tabella_docenti_corsi', 'codice', 'codice_fiscale', string='Docenti abilitati ad erogare edizioni del corso:')

and I've stated that every class has just one teacher (meanwhile a teacher can teach different classes)

DOCENTE.PY (docente=teacher)  -> docente_edizioni = fields.One2many('piani_formazione.edizione','edizione_docente',string="Edizioni che eroga il docente")
EDIZIONE.PY (edizione=class) -> edizione_docente = fields.Many2one('piani_formazione.docente', string="Docente che eroga il corso", required=True)

If i leave the code like it is, then while choosing which teacher will teach a class it could be selected any teacher. What I would like to do is to hide the teachers that cannot teach the class (because they are not qualified to teach the related course) from the possible choices in the class form view (in the many2one field named "edizione_docente"). How could I do it?

I saw online that the operator '=' works as a 'contains', so I tried adding to the Many2one field a domain such as the following, but now the drop down list of the field is always empty

EDIZIONE.PY (edizione=class) -> edizione_docente = fields.Many2one('piani_formazione.docente', string="Docente che eroga il corso", required=True, domain="[('abilitazioni','=','edizione_corso')]" )    

0
Avatar
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse

Hi,

To hide some field in Many2one Here is an example

There are two fields source_location_id and destination_location_id, both of which are Many2one fields referencing the res.country model.

source_location_id = fields.Many2one('res.country',string='Source Location')
destination_location_id = fields.Many2one('res.country',string='Destination Location', domain="[('id', '!=', ""source_location_id)]")

The destination_location_id field has a domain set on it, which filters out the value of the source_location_id field from the dropdown list of destination_location_id. This ensures that the user cannot select the same country as both the source and destination

https://www.cybrosys.com/blog/how-to-apply-dynamic-domain-for-relational-fields-in-odoo-16

Regards

0
Avatar
Ignorer
Avatar
Gustave
Meilleure réponse

Hi, can you try : 

 domain="[('abilitazioni', 'in', [edizione_corso,])]"


Gus

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Odoo 14: How i can set Domain filter on Many2one type field Résolu
many2one v14
Avatar
Avatar
Avatar
2
févr. 25
41873
hide many2one record when changing condition
many2one v14
Avatar
Avatar
Avatar
2
nov. 22
3517
Odoo 14: set filter of Many2one field onchange of another Many2one field
many2one v14
Avatar
Avatar
1
févr. 22
8501
Many2one field is not showing record name on Saving form Résolu
many2one v14
Avatar
Avatar
2
déc. 21
4931
How to set a kanban view to many2one field in Odoo 14 ?
many2one v14
Avatar
0
oct. 21
2885
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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