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

many2one field not showing field values

S'inscrire

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

Cette question a été signalée
pythonfieldsmany2onerelationship
2 Réponses
14319 Vues
Avatar
Suthan

Hi,

Im having a problem linking a many2one field to another many2one field. Im getting numbers like 1,2,3(i think its the record number) instead of the field value in the drop down list.

Below, I have 3 classes Activity code, Activity data, and Activity summary.

Activity summary has a many2one field called 'activity_code' that relates to Activity data and activity data has a many2one field that relates to activity code. I am able to view the field values in the drop down list in activity data form, it works fine, but im not able to view it in Activity summary form. I get numbers

Can anyone tell me why this is happening and how i may fix it to show the intended value instead of the numbers? Below is my code.

Activity code

class activity_yearcode(osv.osv):
 _name = "budget.activity_code"
 _description = "Activity Year Code"
 _rec_name = "activity_code"
 _columns = {
    'activity_code' : fields.char("Activity Code", size=64, required=True),
    'activity_name' : fields.char("Activity Name", size=128),
    'act_status' : fields.selection([
                ('1', 'All'),
                ('2', 'Active'),
                ('3', 'Inactive'),
                ], 'Status'),
    }
_sql_constraints = [
    ('activity_code_unique', 'UNIQUE(activity_code)', 'Each activity code is unique.'),
]

Activity Data - working fine

class activity_data(osv.osv):

_name = "management.activity_data"
_description = "Activity Data"
_rec_name = "activity_data_num"
_columns = {
    'activity_data_num' : fields.char('activity_data_num', size=16),
    'activity_code' : fields.many2one( "budget.activity_code","Activity Code",required=True),
    'management_unit_code' : fields.many2one("budget.org_table","Management Unit Code", required=True),
}
_defaults = {
    'activity_data_num': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'management.activity_data'),
}
_sql_constraints = [
    ('activity_data_num', 'UNIQUE(activity_data_num)', 'Each activity_data_num is unique.'),
]

Activity Summary - In this model, im getting a single digit number instead of the the field value in 'activity_code' field.

class activity_summary(osv.osv):
_name = "work.activity_summary"
_description = "Activity Summary"
_columns = {
    'activity_code' : fields.many2one("management.activity_data", "Activity Code", ondelete= "no action", required=True ),
    'management_code' : fields.related("activity_code", "activity_data_num", "management_unit_code", type = "char", string = "Management code"),
'region_id' : fields.char("Region ID", size=64, required=True),
    'daily_prod' : fields.integer("Daily Prod"),
    'deviation' : fields.integer("Deviation Level"),

             }

Please help..Thank you in advance.

0
Avatar
Ignorer
Avatar
Prakash
Meilleure réponse

Based on your code rec_name field value shows in many2one 1) management.activity_data table many2one relation budget.activity_code table used for the column (List it shows activity_code)

2) work.activity_summary table activity_code many2one relation management.activity_data table used (Lits it shows activity_data_num)

In work.activity_summary table If you want shows activity_code from budget.activity_code table then change the many2one relation into below code:

class activity_summary(osv.osv):
_name = "work.activity_summary"
_description = "Activity Summary"
_columns = {
    'activity_code' : fields.many2one("budget.activity_code", "Activity Code", ondelete= "no action", required=True ),
   }
1
Avatar
Ignorer
Suthan
Auteur

hi, sorry, but still there's no change...

Prakash

Finally I updated my answer based on your code.

Suthan
Auteur

hi, This works fine, so, it relates to the budget.activity code model right. Thank you so much.!

Avatar
Dhinesh
Meilleure réponse

Hi, By default priority will be given for name field if rec_name is not present. Define your required field in rec_name. If you want more than one field value to be displayed means use name_get orm method.

4
Avatar
Ignorer
Suthan
Auteur

thank you..this information was very helpful.

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é
what is ir.property used for? Résolu
fields many2one relationship ir_property
Avatar
Avatar
1
sept. 21
22178
Error with res.partner or hr.employee many2one
python fields many2one openerp7
Avatar
Avatar
Avatar
2
mars 15
7421
Clear field many2one if a checkbox is deselected
fields many2one
Avatar
Avatar
1
janv. 22
4169
Need help with Relational field
fields product many2one relationship product.template
Avatar
0
oct. 20
3600
Adding a new field to the existing model and setting that field value by python method return
python fields
Avatar
0
mai 20
7161
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