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
    • Guest House
    • Distributeur de boissons
    • Hotel
    Real Estate
    • Real Estate Agency
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consulting
    • Accounting Firm
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Cordonnier
    • Services de nettoyage
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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

Model Name in Fleet module?

S'inscrire

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

Cette question a été signalée
fleetmodulecomputed-fields
2 Réponses
5196 Vues
Avatar
7heJumpeR

I want to create Model (car) name like, Telsa / Model X, and I found this piece of code of Fleet module doing that.

FleetVehicleModel class (models.Model) 
_name = 'fleet.vehicle.model'
_description = 'Model of a vehicle'
_order = 'desc'

name = fields.Char ('Model name', required = True)
brand_id = fields. Many2one ('fleet.vehicle.model.brand', 'Make', required = True, help = 'Make of the vehicle')
vendors fields.Many2many = ('res.partner', 'fleet_vehicle_model_vendors',' model_id '' partner_id ', string =' Vendors')
image = fields.Binary (related = 'brand_id.image', string = "Logo", readonly = False)
image_medium = fields.Binary (related = 'brand_id.image_medium', string = "Logo (medium) ",
image_small = fields.Binary (related = 'brand_id.image_small', string = "Logo (small)", readonly = False)

@ api.multi
@ api.depends ('name', 'brand_id')
def name_get (self):
res = []
for record in self:
name = record.name
if record.brand_id.name:
name = record.brand_id.name + '/' + name
res.append ((record.id, name))
return res

I do not understand how this code works when I choose the model then press Save button, it will create a new name under the form "Brand / Model" and replace the old name I filled.
And I did not see any 'computed field' in this model.
I figure out by 'print (res)', but I do not understand how this can link 'record.id' in 'res []' to find the new name.
I also can not find any new fields in Database too.


I will appreciate if someone can explain it.
Many thanks

0
Avatar
Ignorer
Avatar
Niyas Raphy (Walnut Software Solutions)
Meilleure réponse

Hi,

What is your doubt about ? Is it about the name_get function defined ? The methods is called by Odoo core itself, probably you  will never end up calling those by yourself or not needed to have a compute field for that. Those methods are called by some widgets like many2one to get the display name of the record.


Thanks

1
Avatar
Ignorer
7heJumpeR
Auteur

In short, I just want to know Where is list res[] in get_name func stored?

Avatar
7heJumpeR
Auteur Meilleure réponse

Well, I want to create a name of a car in the form like "Model/Brand", e.g: ModelX/Telsa. I call this 'formed name'.

Generally, I will create a field: 

Car_name = fields.Char(computed='get_name')

brand_id = fields.Many2one('car.brand')

model_id = fields.Many2one('car.model')

then I will define a 'computed function' to create 'car_name' like I want.

@api.depends('brand_id', 'model_id')

def get_name(self):

car_name = str(brand_id.name) + '/' + str(model_id.name)

then, I can show car_name in my tree.view or form.view. 

It is ok if I do like that.

BUT, when I read the code in Fleet module, there isn't a 'computed field' (to form the name like I want).

If you read name_get func in Fleet code (like, I quoted above), they just use a list res[], then stored the formed name and the id of the record. Then the 'formed name' appears in the tree.view or form.view after I press the Save button.

I just print the list 'res[]', and it stored the id and the 'formed name' as: [(1, ModelX/Telsa),(2, Vios/Toyota)....]

I just dont understand how they can call the formed name through 'res' list only by the id of the record. I checked in the SQL but cant find any field store 'formed name'.

In short, I just want to know Where is list res[] in get_name func stored?

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é
computed field doesnt work with a domain
fleet computed-fields v15
Avatar
0
avr. 24
2229
Update fleet vehicule
fleet module update
Avatar
Avatar
1
févr. 19
3788
fleet management offline
fleet
Avatar
Avatar
Avatar
2
oct. 25
570
ValueError: forbidden opcode(s) in 'lambda': STORE_ATTR
computed-fields
Avatar
Avatar
1
juin 25
16726
Make stored compute filed recompute after changing it logic but not depedencies.
computed-fields
Avatar
Avatar
Avatar
Avatar
3
avr. 25
7297
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