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

_rec_name - predefined fields

S'inscrire

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

Cette question a été signalée
fieldspredefined_rec_name
12 Réponses
56808 Vues
Avatar
omprakash

Hai Friends ,

 First I thank everyone who give good guideline for newbie in OpenERP . I have question regards predefined fields - _rec_name  in OpenERP .
  1. Its not clear for me , _rec_name predefined fields in OpenERP . Friends can you please explain with sample module .It more useful for clear understanding .

Thanks & Regards OMPRAKASH.A

0
Avatar
Ignorer
Odoo Mates

See this video to understand use of the rec_name and how to set it for a model: https://www.youtube.com/watch?v=d_cyPsVc7vg

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Meilleure réponse

_name is used to define object like account.invoice, sale.order, purchase.order, res.users.

When you have name field in your columns, you don't need to define field in _rec_name. OpenERP takes name field by default.

You have seen name in any form when you select many2one field. For example in Sale Order when you select Customer, you can see Customer's Name in that many2one field. Now if you want to show Customer's Phone Number in many2one field, you have to define phone field in _rec_name like this: _rec_name = 'phone'

If your columns don't have any name field then you have to define any field in _rec_name.

There are other reasons which Prakash described in his answer.

12
Avatar
Ignorer
omprakash
Auteur

Hi Sudhir Arya, Thanks for your reply . I am new for OpenERP , If my question are very silly please don't mistake . I am very interest to know about OpenERP . 1. > From your point I can understand that _rec_name not needed until _name is defined . But if i create a <objectname>.py class _name is mandatory . So I must declare the _name fields . 2.> If i define _rec_name how can i make use .

omprakash
Auteur

This is my sample code please explain with this ...< Test.py > from osv import fields,osv class test(osv.osv): _name = 'sodexis' _rec_name = 'data_id' _columns = { 'name' : fields.char('name' , required = 1 , size = 30 ), 'age' : fields.integer('age' , store = False), 'data_id':fields.many2one('test', 'data_id', required=False) } test()

omprakash
Auteur

Please explain with this example , And once i thank you both for such guideline ... Thanks regards ----OMPRAKASH.A

Sudhir Arya (ERP Harbor Consulting Services)

I am talking about name field in _columns not _name. There is nothing to do with _name.

Sudhir Arya (ERP Harbor Consulting Services)

In your code you have defined name field

`name`: fields.char('name', required=1, size=30)

So you don't need to define _rec_name because OpenERP takes name field by by default.

omprakash
Auteur

Hi Suhir Arya , Thanks for your reply ..

Avatar
Prakash
Meilleure réponse

In fields.many2one("table.name", output)

Default name_get method return the output value "name" field value in the table.

suppose in the table contain no "name" field then we can use _rec_name = field_name

Now in name_get method return _rec_name field value.

0
Avatar
Ignorer
omprakash
Auteur

Hi Prakash , Thanks for your reply . I have doubt , _name is mandatory then how can I use _rec_name ? If you explain with sample code , It make more useful for me & once again thanks for your reply

Jainesh Shah(Aktiv Software)

Hi omprakash, Here is the sample code.

Class Test(models.Model):

_name = 'test'

_rec_name = field_1

field_1 = fields.Many2one('object',"Field 1")

field_2 = fields.Many2one('object',"Field 2")

date = fields.Date("Date")

As you can see no "name" field is there in above model.

So here we have 2 option :

Option 1: set rec_name :- Here field which is set in rec_name works as Model name field.

Option 2: override name_get method :- We need to override name_get method.(here we can concate more than 2 fields and create name for model)

@api.multi

@api.depends('field_1', 'date')

def name_get(self):

result = []

for test in self:

name = test.field_1 + ' ' + account.date

result.append((test.id, name))

return result

Avatar
Nivas
Meilleure réponse

Hi,

I have another doubt here.I want to know the way to find which field is applied in _rec_name in the particular model.

I have taken that model id from ir.model table and also I could find all the fields list created in that model through ir.model.fields table.But I could not find which field is used in _rec_name

Could you please help me?


0
Avatar
Ignorer
Avatar
subbarao
Meilleure réponse

_rec_name name by default looks for name field, if name field is not available then it will display like your model_name,db_id , so we have to pass at least one field to _rec_name in case of no name field.

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é
_auto & _sql predefined fields
fields _auto _sql predefined
Avatar
Avatar
1
oct. 22
12998
_sequence predefined fields
fields _sequence predefined attributes
Avatar
Avatar
1
juil. 15
7772
How to display a red * for required fields
fields
Avatar
Avatar
Avatar
Avatar
3
mai 25
3374
How to display a red * for required fields
fields
Avatar
Avatar
1
avr. 25
2404
one2one relational field Résolu
fields
Avatar
Avatar
Avatar
Avatar
3
sept. 24
16063
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