Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

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

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
one2manyon_changeeditingv8.0
5356 Tampilan
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
Buang
Baiju KS

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

Randy Raharjo
Penulis

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.

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How to stop editing if an validation error take place in tree view ?
one2many on_change editing validation
Avatar
0
Mar 15
4623
How to use Onchange function in one2many
one2many on_change
Avatar
Avatar
1
Mar 15
6604
create and edit items of a one2many field through on_change method
one2many on_change active_id
Avatar
0
Jan 17
9650
Dataerror updating function field of one2many object using on_change event
one2many on_change function_field
Avatar
0
Mar 15
5783
is there any way to unlink line items on onchange?
one2many on_change line
Avatar
Avatar
1
Mar 15
9094
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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