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

Trying to show informations

S'inscrire

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

Cette question a été signalée
functionfieldlistview
1 Répondre
5483 Vues
Avatar
Lawrence

I'm trying to display function fields in a sort of listview (not editable). Something like Customer Invoices in Accounting.

Here is my current code. (py) I use a function field with a range, etc just to do a test.

def _get_partners(self, cr, uid, ids, name, arg, context):
res = {}
partners_obj = self.pool.get('res.partner')
listIds = range(1, 10000)
partners_list = partners_obj.search(cr, uid, [('id', 'in', listIds)])
for element in partners_list:
    partner = partners_obj.browse(cr,uid, element)
    partner_name = partner.name
    res[partner.id] = partner_name
print(res)
return res

_name = 'aged.partner.balance'   
_description = 'Aged Partner Balance'
_columns = {
    'partner_id': fields.function(_get_partners, type='char', store=False, method=True,)

aged_partner_balance()

<record id="aged_partner_tree" model="ir.ui.view"> <field name="name">aged.partner.balance.tree</field> <field name="model">aged.partner.balance</field> <field name="arch" type="xml"> <tree string="Aged Partner Balance" >="" <field="" name="partner_id" string="Name"/> </tree>
</field> </record>

0
Avatar
Ignorer
Andreas Tolstov

and where is the question?

Lawrence
Auteur

ops ye. well It doesnt show the information that my function return. I see 'name' and nothing else. Wondering what i did wrong

Avatar
Cyril Gaspard (GEM)
Meilleure réponse

Hi,

try this :

in your function _get_partners, you must find list of ids you need corresponding to result you want :

def _get_partners(self, cr, uid, ids, name, arg, context):
    if context is None:
        context = {}
    res = {}
    for info in self.browse(cr, uid, ids, context=context):
        cr.execute("""SELECT id FROM res_partner WHERE id BETWEEN 1 AND 10000""")
        list_ids = cr.dictfetchall()
        if list_ids:
            final_list = []
            for info in list_ids:
                 final_list.apend(info)
            res[info.id] = final_list
    print res
    return res

_name = 'aged.partner.balance'   
_description = 'Aged Partner Balance'
_columns = {
    'partner_ids': fields.function(_get_partners, type='one2many' relation='res.partner', method=True, string='Name displayed field')

Hope this will help and work.

Bye

1
Avatar
Ignorer
Cyril Gaspard (GEM)

I update my answer to add possibility to display the tree. Bye

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é
Function field issue
function field
Avatar
Avatar
1
mars 15
4867
Purchase Order Function Field Issue
function field
Avatar
0
mars 15
4541
Can you check a code of my module : filed. function
function field
Avatar
Avatar
2
mars 15
5404
Why I get this 'str' object is not callable error with my new function field? Résolu
function error field
Avatar
Avatar
2
févr. 17
8582
separate long name into several field Résolu
function fields field
Avatar
Avatar
1
mars 15
6225
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