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

Why on_change method with one2many parameter return ids instead of value?

S'inscrire

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

Cette question a été signalée
one2manyon_changeeditingv8.0
5344 Vues
Avatar
Randy Raharjo

I have two module, one parent and one child modules. Parent module have one2many field to child module. I put on_change method in the one2many field with parameter is the field itself.

In on_change method(.py file) when creating new line in one2many field, the parameter looks like

[(0,0,{value})]

Then, I save the module, and try to edit the one2many field.

It give me

[(6,0,[xx,xy])]

with xx and xy are id's of child.

My question is, when I change some value in child's field, how can parent know the changed value in child's field.

I already tried to browse the record of xx, and xy. It gives me the old value stored in db.

Someone pls enlighten me!

--------------------------------------------------------- EDIT ( Adding the code and some more explanation about the condition)

This is the parent XML, Field childList has on_change method that have itself as parameter

<record id="parent_form" model="ir.ui.view">
            <field name="name">belajar.parent.form</field>
            <field name="model">belajar.parent</field>
            <field name="arch" type="xml">
                <form string="Parent" version="7.0" >
                    <group>
                        <field name="name"/>
                        <field name="childList" on_change="onchange_childList(childList)"/>
                    </group>
                </form>
            </field>
        </record>

This is parent class

class parentA(osv.osv):
    _name = 'belajar.parent'
    _description = "Belajar one2many"
    
    _columns = {
            'name': fields.char("Parent"),
            'childList': fields.one2many("belajar.child","parent","ChildList"),
            }
    
    def onchange_childList(self,cr,uid,ids,cl,context=None):
        res = {}
        print cl
        return {'value': res}

This is Child XML

<record id="child_form" model="ir.ui.view">
            <field name="name">belajar.child.form</field>
            <field name="model">belajar.child</field>
            <field name="arch" type="xml">
                <form string="child" version="7.0" >
                    <group>
                        <field name="name"/>
                    </group>
                </form>
            </field>
        </record>

This is child Class

class childA(osv.osv):
    _name = 'belajar.child'
    _description = "Belajar one2many"
    _columns = {
            'name': fields.char("Child"),
            'parent': fields.many2one("belajar.parent" , "Parent"),
            }

When user editing child record in one2many field at parent form, it goes to onchange_childList and print some value. That value is different depending on the situation:

  • When creating new row /  editing that new row it returns [(0,0,{value})]
  • When editing existing row ( row from record that has been saved / created ) it return [(0,0,[xx,xy])

How can I get user value form existing row? It only gives me the ID.

0
Avatar
Ignorer
Baiju KS

Hi,, Are you editing the values from view part or by using code??

Randy Raharjo
Auteur

Hi, thanks for the reply. I am editing from view part. Like normal user would do. Then I want the user's value to be passed to parent, in on_change method.

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é
How to stop editing if an validation error take place in tree view ?
one2many on_change editing validation
Avatar
0
mars 15
4606
How to use Onchange function in one2many
one2many on_change
Avatar
Avatar
1
mars 15
6604
create and edit items of a one2many field through on_change method
one2many on_change active_id
Avatar
0
janv. 17
9649
Dataerror updating function field of one2many object using on_change event
one2many on_change function_field
Avatar
0
mars 15
5782
is there any way to unlink line items on onchange?
one2many on_change line
Avatar
Avatar
1
mars 15
9089
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